diff options
| author | 2023-08-19 18:17:16 -0700 | |
|---|---|---|
| committer | 2023-08-19 18:17:16 -0700 | |
| commit | 507761b4637a83d10e2f8b64ff870881bba7c14b (patch) | |
| tree | cb3a2920ed18832df3c7075bd8e21b15b1184a3d /src/bun.js/base.zig | |
| parent | 196620183fd20ca42b363c5f947af1dc979f888f (diff) | |
| download | bun-507761b4637a83d10e2f8b64ff870881bba7c14b.tar.gz bun-507761b4637a83d10e2f8b64ff870881bba7c14b.tar.zst bun-507761b4637a83d10e2f8b64ff870881bba7c14b.zip | |
Fix crash impacting sharp & resvg (#4221)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/bun.js/base.zig')
| -rw-r--r-- | src/bun.js/base.zig | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/src/bun.js/base.zig b/src/bun.js/base.zig index dbb208284..b08b82c40 100644 --- a/src/bun.js/base.zig +++ b/src/bun.js/base.zig @@ -771,44 +771,6 @@ comptime { std.testing.refAllDecls(RefString); } -// TODO: remove this abstraction and make it work directly with -pub const ExternalBuffer = struct { - global: *JSC.JSGlobalObject, - ctx: ?*anyopaque = null, - function: JSC.napi.napi_finalize = null, - allocator: std.mem.Allocator, - buf: []u8 = &[_]u8{}, - - pub fn create(ctx: ?*anyopaque, buf: []u8, global: *JSC.JSGlobalObject, function: JSC.napi.napi_finalize, allocator: std.mem.Allocator) !*ExternalBuffer { - var container = try allocator.create(ExternalBuffer); - container.* = .{ - .ctx = ctx, - .global = global, - .allocator = allocator, - .function = function, - .buf = buf, - }; - return container; - } - - pub fn toJS(this: *ExternalBuffer, ctx: *JSC.JSGlobalObject) JSC.JSValue { - return JSC.JSValue.createBufferWithCtx(ctx, this.buf, this, ExternalBuffer_deallocator); - } - - pub fn toArrayBuffer(this: *ExternalBuffer, ctx: *JSC.JSGlobalObject) JSC.JSValue { - return JSValue.c(JSC.C.JSObjectMakeArrayBufferWithBytesNoCopy(ctx.ref(), this.buf.ptr, this.buf.len, ExternalBuffer_deallocator, this, null)); - } -}; -pub export fn ExternalBuffer_deallocator(bytes_: *anyopaque, ctx: *anyopaque) callconv(.C) void { - var external: *ExternalBuffer = bun.cast(*ExternalBuffer, ctx); - if (external.function) |function| { - function(external.global, external.ctx, bytes_); - } - - const allocator = external.allocator; - allocator.destroy(external); -} - pub export fn MarkedArrayBuffer_deallocator(bytes_: *anyopaque, _: *anyopaque) void { const mimalloc = @import("../allocators/mimalloc.zig"); // zig's memory allocator interface won't work here |
