Files
bun.sh/src/http/zlib.zig
pfg 83760fc446 Sort imports in all files (#21119)
Co-authored-by: taylor.fish <contact@taylor.fish>
2025-07-21 13:26:47 -07:00

35 lines
1006 B
Zig

fn initMutableString(allocator: std.mem.Allocator) anyerror!MutableString {
return MutableString.initEmpty(allocator);
}
const BufferPool = bun.ObjectPool(MutableString, initMutableString, false, 4);
pub fn get(allocator: std.mem.Allocator) *MutableString {
return &BufferPool.get(allocator).data;
}
pub fn put(mutable: *MutableString) void {
mutable.reset();
var node: BufferPool.Node = @fieldParentPtr("data", mutable);
node.release();
}
pub fn decompress(compressed_data: []const u8, output: *MutableString, allocator: std.mem.Allocator) Zlib.ZlibError!void {
var reader = try Zlib.ZlibReaderArrayList.initWithOptionsAndListAllocator(
compressed_data,
&output.list,
output.allocator,
allocator,
.{
.windowBits = 15 + 32,
},
);
try reader.readAll();
reader.deinit();
}
const Zlib = @import("../zlib.zig");
const std = @import("std");
const bun = @import("bun");
const MutableString = bun.MutableString;