usingnamespace @import("string_types.zig"); const Allocator = @import("std").mem.Allocator; const assert = @import("std").debug.assert; const copy = @import("std").mem.copy; const StringBuilder = @This(); len: usize = 0, cap: usize = 0, ptr: ?[*]u8 = null, pub fn count(this: *StringBuilder, slice: string) void { this.cap += slice.len; } pub fn allocate(this: *StringBuilder, allocator: *Allocator) !void { var slice = try allocator.alloc(u8, this.cap); this.ptr = slice.ptr; this.len = 0; } pub fn append(this: *StringBuilder, slice: string) string { assert(this.len <= this.cap); // didn't count everything assert(this.ptr != null); // must call allocate first copy(u8, this.ptr.?[this.len..this.cap], slice); const result = this.ptr.?[this.len..this.cap][0..slice.len]; this.len += slice.len; assert(this.len <= this.cap); return result; } Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
path: root/src/linker.zig (unfollow)
AgeCommit message (Expand)AuthorFilesLines
2022-10-10Use write() and read() since not every file type supports positionalGravatar Jarred Sumner 1-7/+6
2022-10-10Handle EAGAIN in Bun.write() for short inputGravatar Jarred Sumner 1-4/+63
2022-10-10Ensure we set globalThis in the FileBlob / FileSinkGravatar Jarred Sumner 1-0/+2
2022-10-10Support cache with same name applied to multiple gettersGravatar Jarred Sumner 2-11/+26
2022-10-10Fix issue with exit callback in Bun.spawn() never firingGravatar Jarred Sumner 5-13/+115
2022-10-10Process inherits from EventEmitterGravatar Jarred Sumner 2-14/+12