Migrate url_proxy_buffer and hostname fields from raw pointers to
bun.ptr.Owned for explicit ownership tracking and automatic cleanup.
Changes to SharedData struct:
- url_proxy_buffer: []const u8 → bun.ptr.Owned([]const u8)
- hostname: ?[]u8 → ?bun.ptr.Owned([]u8)
Ownership improvements:
- Explicit ownership: Clear who owns the memory
- Automatic cleanup: Single deinit() call handles everything
- Type safety: Can't accidentally forget to free
- Zero overhead: Uses bun.DefaultAllocator (zero-sized type)
Implementation details:
- SharedData.init(): Initialize url_proxy_buffer with fromRaw(&.{})
- SharedData.deinit(): Call deinit() on owned pointers
- FetchTasklet.get(): Use fromRaw() to take ownership from fetch.zig
- AsyncHTTP.init(): Use .get() accessor to extract raw pointer
Ownership lifecycle:
1. Allocation in fetch.zig (creates raw buffer)
2. Transfer via fromRaw() to FetchTasklet SharedData
3. Storage for lifetime of fetch operation
4. Automatic cleanup via deinit()
Mutable pointer pattern for optional deinit:
- if (self.hostname) |*hostname| hostname.deinit()
- Captures mutable pointer required for deinit() method
All usage sites updated:
- 2 field declarations (SharedData struct)
- 1 initialization site (SharedData.init)
- 2 cleanup sites (SharedData.deinit)
- 2 ownership transfer sites (FetchTasklet.get)
- 1 access site (AsyncHTTP.init for hostname)
Verified:
- Compiles successfully with no errors
- All ownership transfers use fromRaw()
- All access sites use .get() where needed
- Proper mutable pointer capture for optional deinit
- No missing usage sites
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>