Added build option to enable the leak counting allocator.

Log the allocation count to the client at the end of the main loop.
Fixed two memory leaks in analysis.zig
This commit is contained in:
Alexandros Naskos
2020-05-07 12:50:25 +03:00
parent 5bd790f416
commit 0283222e3a
3 changed files with 29 additions and 6 deletions

View File

@@ -30,12 +30,13 @@ pub fn getDocComments(allocator: *std.mem.Allocator, tree: *std.zig.ast.Tree, no
if (func.doc_comments) |doc_comments| {
var doc_it = doc_comments.lines.iterator(0);
var lines = std.ArrayList([]const u8).init(allocator);
defer lines.deinit();
while (doc_it.next()) |doc_comment| {
_ = try lines.append(std.fmt.trim(tree.tokenSlice(doc_comment.*)[3..]));
}
return try std.mem.join(allocator, "\n", lines.toOwnedSlice());
return try std.mem.join(allocator, "\n", lines.items);
} else {
return null;
}
@@ -45,12 +46,13 @@ pub fn getDocComments(allocator: *std.mem.Allocator, tree: *std.zig.ast.Tree, no
if (var_decl.doc_comments) |doc_comments| {
var doc_it = doc_comments.lines.iterator(0);
var lines = std.ArrayList([]const u8).init(allocator);
defer lines.deinit();
while (doc_it.next()) |doc_comment| {
_ = try lines.append(std.fmt.trim(tree.tokenSlice(doc_comment.*)[3..]));
}
return try std.mem.join(allocator, "\n", lines.toOwnedSlice());
return try std.mem.join(allocator, "\n", lines.items);
} else {
return null;
}