@@ -130,17 +130,17 @@ fn updateVersionInJson(allocator: Allocator, content: []const u8, old_version: [
130130 try obj .put ("version" , .{ .string = version_str });
131131
132132 // Serialize back to JSON with pretty printing
133- var output = std .ArrayList (u8 ). init ( allocator ) ;
134- defer output .deinit ();
133+ var output : std .ArrayList (u8 ) = .empty ;
134+ defer output .deinit (allocator );
135135
136136 try std .json .stringify (root , .{
137137 .whitespace = .indent_2 ,
138- }, output .writer ());
138+ }, output .writer (allocator ));
139139
140140 // Add newline at end
141- try output .append ('\n ' );
141+ try output .append (allocator , '\n ' );
142142
143- return try output .toOwnedSlice ();
143+ return try output .toOwnedSlice (allocator );
144144}
145145
146146fn findVersionInToml (allocator : Allocator , content : []const u8 ) ! ? []u8 {
@@ -174,8 +174,8 @@ fn findVersionInToml(allocator: Allocator, content: []const u8) !?[]u8 {
174174fn updateVersionInToml (allocator : Allocator , content : []const u8 , old_version : []const u8 , new_version : []const u8 ) ! []u8 {
175175 _ = old_version ;
176176
177- var output = std .ArrayList (u8 ). init ( allocator ) ;
178- defer output .deinit ();
177+ var output : std .ArrayList (u8 ) = .empty ;
178+ defer output .deinit (allocator );
179179
180180 var lines = std .mem .splitScalar (u8 , content , '\n ' );
181181 var line_index : usize = 0 ;
@@ -186,36 +186,38 @@ fn updateVersionInToml(allocator: Allocator, content: []const u8, old_version: [
186186 if (std .mem .startsWith (u8 , trimmed , "version" )) {
187187 // Check if this is a version field assignment
188188 const eq_index = std .mem .indexOfScalar (u8 , trimmed , '=' ) orelse {
189- try output .appendSlice (line );
190- if (lines .rest ().len > 0 ) try output .append ('\n ' );
189+ try output .appendSlice (allocator , line );
190+ if (lines .rest ().len > 0 ) try output .append (allocator , '\n ' );
191191 continue ;
192192 };
193193
194194 const value_part = std .mem .trim (u8 , trimmed [eq_index + 1 .. ], & std .ascii .whitespace );
195195 if (value_part .len >= 2 and (value_part [0 ] == '"' or value_part [0 ] == '\' ' )) {
196196 // This is a version field, replace it
197197 const leading_space = std .mem .indexOfScalar (u8 , line , 'v' ) orelse 0 ;
198- try output .appendSlice (line [0.. leading_space ]);
199- try output .writer ().print ("version = \" {s}\" " , .{new_version });
198+ try output .appendSlice (allocator , line [0.. leading_space ]);
199+ const replacement = try std .fmt .allocPrint (allocator , "version = \" {s}\" " , .{new_version });
200+ defer allocator .free (replacement );
201+ try output .appendSlice (allocator , replacement );
200202 } else {
201- try output .appendSlice (line );
203+ try output .appendSlice (allocator , line );
202204 }
203205 } else {
204- try output .appendSlice (line );
206+ try output .appendSlice (allocator , line );
205207 }
206208
207- if (lines .rest ().len > 0 ) try output .append ('\n ' );
209+ if (lines .rest ().len > 0 ) try output .append (allocator , '\n ' );
208210 }
209211
210- return try output .toOwnedSlice ();
212+ return try output .toOwnedSlice (allocator );
211213}
212214
213215fn findVersionInText (allocator : Allocator , content : []const u8 ) ! ? []u8 {
214216 // Look for semantic version patterns in text
215217 // Pattern: \bX.Y.Z\b (word boundaries)
216218 const semver_pattern = std .mem .indexOf (u8 , content , "0." ) orelse
217- std .mem .indexOf (u8 , content , "1." ) orelse
218- return null ;
219+ std .mem .indexOf (u8 , content , "1." ) orelse
220+ return null ;
219221
220222 // Extract the version starting from this position
221223 var end = semver_pattern ;
@@ -238,8 +240,8 @@ fn findVersionInText(allocator: Allocator, content: []const u8) !?[]u8 {
238240
239241fn updateVersionInText (allocator : Allocator , content : []const u8 , old_version : []const u8 , new_version : []const u8 ) ! []u8 {
240242 // Simple find and replace with word boundary consideration
241- var output = std .ArrayList (u8 ). init ( allocator ) ;
242- defer output .deinit ();
243+ var output : std .ArrayList (u8 ) = .empty ;
244+ defer output .deinit (allocator );
243245
244246 var pos : usize = 0 ;
245247 while (pos < content .len ) {
@@ -256,20 +258,20 @@ fn updateVersionInText(allocator: Allocator, content: []const u8, old_version: [
256258
257259 // Only replace if we have word boundaries on both sides
258260 if (has_boundary_before and has_boundary_after ) {
259- try output .appendSlice (content [pos .. abs_index ]);
260- try output .appendSlice (new_version );
261+ try output .appendSlice (allocator , content [pos .. abs_index ]);
262+ try output .appendSlice (allocator , new_version );
261263 pos = end_index ;
262264 } else {
263- try output .appendSlice (content [pos .. abs_index + 1 ]);
265+ try output .appendSlice (allocator , content [pos .. abs_index + 1 ]);
264266 pos = abs_index + 1 ;
265267 }
266268 } else {
267- try output .appendSlice (remaining );
269+ try output .appendSlice (allocator , remaining );
268270 break ;
269271 }
270272 }
271273
272- return try output .toOwnedSlice ();
274+ return try output .toOwnedSlice (allocator );
273275}
274276
275277fn isVersionChar (c : u8 ) bool {
@@ -279,12 +281,12 @@ fn isVersionChar(c: u8) bool {
279281pub fn findFiles (allocator : Allocator , dir_path : []const u8 , recursive : bool , pattern : ? []const u8 ) ! [][]u8 {
280282 _ = pattern ;
281283
282- var files = std .ArrayList ([]u8 ). init ( allocator ) ;
284+ var files : std .ArrayList ([]u8 ) = .empty ;
283285 errdefer {
284286 for (files .items ) | file | {
285287 allocator .free (file );
286288 }
287- files .deinit ();
289+ files .deinit (allocator );
288290 }
289291
290292 if (recursive ) {
@@ -295,13 +297,13 @@ pub fn findFiles(allocator: Allocator, dir_path: []const u8, recursive: bool, pa
295297 defer allocator .free (package_json_path );
296298
297299 std .fs .cwd ().access (package_json_path , .{}) catch {
298- return files .toOwnedSlice ();
300+ return files .toOwnedSlice (allocator );
299301 };
300302
301- try files .append (try allocator .dupe (u8 , package_json_path ));
303+ try files .append (allocator , try allocator .dupe (u8 , package_json_path ));
302304 }
303305
304- return try files .toOwnedSlice ();
306+ return try files .toOwnedSlice (allocator );
305307}
306308
307309fn findFilesRecursive (allocator : Allocator , files : * std .ArrayList ([]u8 ), dir_path : []const u8 ) ! void {
@@ -332,7 +334,7 @@ fn findFilesRecursive(allocator: Allocator, files: *std.ArrayList([]u8), dir_pat
332334 .file = > {
333335 const file_type = FileType .fromPath (entry .name );
334336 if (file_type == .package_json or file_type .isTomlFile ()) {
335- try files .append (try allocator .dupe (u8 , full_path ));
337+ try files .append (allocator , try allocator .dupe (u8 , full_path ));
336338 }
337339 },
338340 else = > {},
0 commit comments