feat(node/net): add SocketAddress (#17154)

Co-authored-by: DonIsaac <22823424+DonIsaac@users.noreply.github.com>
This commit is contained in:
Don Isaac
2025-02-24 11:18:16 -08:00
committed by GitHub
parent 7a35567b45
commit 61edc58362
28 changed files with 1617 additions and 202 deletions

View File

@@ -96,7 +96,7 @@ pub const WTFStringImplStruct = extern struct {
pub inline fn deref(self: WTFStringImpl) void {
JSC.markBinding(@src());
const current_count = self.refCount();
bun.assert(current_count > 0);
bun.assert(self.hasAtLeastOneRef()); // do not use current_count, it breaks for static strings
Bun__WTFStringImpl__deref(self);
if (comptime bun.Environment.allow_assert) {
if (current_count > 1) {
@@ -108,11 +108,16 @@ pub const WTFStringImplStruct = extern struct {
pub inline fn ref(self: WTFStringImpl) void {
JSC.markBinding(@src());
const current_count = self.refCount();
bun.assert(current_count > 0);
bun.assert(self.hasAtLeastOneRef()); // do not use current_count, it breaks for static strings
Bun__WTFStringImpl__ref(self);
bun.assert(self.refCount() > current_count or self.isStatic());
}
pub inline fn hasAtLeastOneRef(self: WTFStringImpl) bool {
// WTF::StringImpl::hasAtLeastOneRef
return self.m_refCount > 0;
}
pub fn toLatin1Slice(this: WTFStringImpl) ZigString.Slice {
this.ref();
return ZigString.Slice.init(this.refCountAllocator(), this.latin1Slice());