adaptiveCalloc top-level constant

Allocator const adaptiveCalloc

A zero-initializing allocator that compile away to calloc in release builds.

  • In debug and profile builds, this allocator records allocation metadata when leak tracking is enabled. It integrates with the leak tracker to record allocation metadata so that native memory leaks can be detected and reported.
  • In release builds, it aliases directly to calloc with zero runtime overhead.

Platform behavior:

  • Windows: uses CoTaskMemAlloc / CoTaskMemFree
  • POSIX: uses calloc / free

This is the recommended allocator for Win32 interop. Prefer it over adaptiveMalloc unless the native API you are calling fully overwrites the allocated buffer and initialization overhead is measurable.

Use diagnosticCalloc instead if you need leak tracking to remain active in release builds.

Implementation

const Allocator adaptiveCalloc = isReleaseMode ? calloc : diagnosticCalloc;