Skip to content

Operations

MaulingMonkey edited this page May 2, 2025 · 1 revision

Mulling over allocator-related operations, current traits, possible future traits, etc.

Parameterization

Init flavor:

  • Zeroed (always available by combining alloc with memset)
  • Debug Pattern Filled (always available by combining alloc with e.g. memset)
  • Uninit (always available, but might use an alternative memory flavor)

Sizing:

  • NonZeroUsize | NonZeroU32 - always available, but may OOM
  • usize | u32 - may always fail for some allocators. Rounding up to size 1 via adapters is sane, but not for FFI allocators, which might be incompatible with sized frees.
  • (element_size, element_count) - some allocators expose this directly

Alignment:

  • Runtime Parameter (e.g. alloc(size: ..., align: Alignment))
  • Generic Parameter (e.g. alloc<const A : Alignment>(size: ...)
  • Implied by object type (e.g. alignof(CONTEXT) → 16)
  • Implied by object size (e.g. 1 → 1, 9001 → alignof(max_align_t)) Common for C/C++ consumers, unthinkable for Rust consumers.

Pointerage:

  • Never-dangling
  • Non-null, but can dangle
  • Nullable

Operations

  • alloc
  • resize - comes in several flavors: zst friendly, zst unfriendly, and resize_or_free
  • free
  • query (size, stats, info, metadata, ...)
  • debug checks (validation, ...)
Clone this wiki locally