UDP support (#7271)

Co-authored-by: Georgijs Vilums <georgijs@bun.sh>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: gvilums <gvilums@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: Jarred-Sumner <Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Georgijs <48869301+gvilums@users.noreply.github.com>
Co-authored-by: Georgijs Vilums <=>
This commit is contained in:
Ashcon Partovi
2024-04-26 15:25:24 -07:00
committed by GitHub
parent a6d39e14fc
commit 589f941aea
31 changed files with 3066 additions and 309 deletions

View File

@@ -158,6 +158,17 @@ pub const WTFStringImplStruct = extern struct {
);
}
pub fn toOwnedSliceZ(this: WTFStringImpl, allocator: std.mem.Allocator) [:0]u8 {
if (this.is8Bit()) {
if (bun.strings.toUTF8FromLatin1Z(allocator, this.latin1Slice()) catch bun.outOfMemory()) |utf8| {
return utf8.items[0 .. utf8.items.len - 1 :0];
}
return allocator.dupeZ(u8, this.latin1Slice()) catch bun.outOfMemory();
}
return bun.strings.toUTF8AllocZ(allocator, this.utf16Slice()) catch bun.outOfMemory();
}
pub fn toUTF8IfNeeded(this: WTFStringImpl, allocator: std.mem.Allocator) ?ZigString.Slice {
if (this.is8Bit()) {
if (bun.strings.toUTF8FromLatin1(allocator, this.latin1Slice()) catch bun.outOfMemory()) |utf8| {