-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove some usingnamespaces #18765
remove some usingnamespaces #18765
Conversation
Updated 2:08 PM PT - Apr 10th, 2025
✅ @paperclover, your commit 95cb524a34c58cdb7d1ba814fdf356b1d334ed2f passed in 🧪 try this PR locally: bunx bun-pr 18765 |
} | ||
|
||
fn free(ctx: *anyopaque, buf: []u8, alignment: std.mem.Alignment, ret_addr: usize) void { | ||
const scope: *AllocationScope = @ptrCast(@alignCast(ctx)); | ||
scope.state.mutex.lock(); | ||
defer scope.state.mutex.unlock(); | ||
var invalid = false; | ||
const invalid = scope.trackFreeAssumeLocked(buf, ret_addr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this return true for 0?
const buf = alloc(u8, 0);
defer free(buf);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std.mem.Allocator special cases zero length allocations and frees to do nothing
@@ -979,7 +979,10 @@ pub fn CAresLookup(comptime cares_type: type, comptime type_name: []const u8) ty | |||
next: ?*@This() = null, | |||
name: []const u8, | |||
|
|||
pub usingnamespace bun.New(@This()); | |||
pub fn new(data: @This()) *@This() { | |||
bun.assert(data.allocated); // deinit will not free this otherwise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should remove .allocated
in the future. It exists because we have allocations going through globalThis.allocator
and bun.default_allocator.destroy
in ResolveInfoRequest.init
and onCaresComplete
Revival of previous PR #18353