Files
bun.sh/src/ptr.zig
taylor.fish 3d361c8b49 Static allocator polymorphism (#22227)
* Define a generic allocator interface to enable static polymorphism for
allocators (see `GenericAllocator` in `src/allocators.zig`). Note that
`std.mem.Allocator` itself is considered a generic allocator.
* Add utilities to `bun.allocators` for working with generic allocators.
* Add a new namespace, `bun.memory`, with basic utilities for working
with memory and objects (`create`, `destroy`, `initDefault`, `deinit`).
* Add `bun.DefaultAllocator`, a zero-sized generic allocator type whose
`allocator` method simply returns `bun.default_allocator`.
* Implement the generic allocator interface in `AllocationScope` and
`MimallocArena`.
* Improve `bun.threading.GuardedValue` (now `bun.threading.Guarded`).
* Improve `bun.safety.AllocPtr` (now `bun.safety.CheckedAllocator`).

(For internal tracking: fixes STAB-1085, STAB-1086, STAB-1087,
STAB-1088, STAB-1089, STAB-1090, STAB-1091)
2025-09-03 15:40:44 -07:00

30 lines
1.3 KiB
Zig

//! The `ptr` module contains smart pointer types that are used throughout Bun.
pub const Cow = @import("./ptr/Cow.zig").Cow;
pub const CowSlice = @import("./ptr/CowSlice.zig").CowSlice;
pub const CowSliceZ = @import("./ptr/CowSlice.zig").CowSliceZ;
pub const CowString = CowSlice(u8);
pub const owned = @import("./ptr/owned.zig");
pub const Owned = owned.Owned; // owned pointer allocated with default allocator
pub const OwnedIn = owned.OwnedIn; // owned pointer allocated with specific type of allocator
pub const DynamicOwned = owned.Dynamic; // owned pointer allocated with any `std.mem.Allocator`
pub const shared = @import("./ptr/shared.zig");
pub const Shared = shared.Shared;
pub const AtomicShared = shared.AtomicShared;
pub const ref_count = @import("./ptr/ref_count.zig");
/// Deprecated; use `Shared(*T)`.
pub const RefCount = ref_count.RefCount;
/// Deprecated; use `AtomicShared(*T)`.
pub const ThreadSafeRefCount = ref_count.ThreadSafeRefCount;
/// Deprecated; use `Shared(*T)`.
pub const RefPtr = ref_count.RefPtr;
pub const TaggedPointer = @import("./ptr/tagged_pointer.zig").TaggedPointer;
pub const TaggedPointerUnion = @import("./ptr/tagged_pointer.zig").TaggedPointerUnion;
/// Deprecated; use `Shared(*T).Weak`.
pub const WeakPtr = @import("./ptr/weak_ptr.zig").WeakPtr;