BSON_ALIGNED_ALLOC(3)

okay bestie, welcome to the BSON_ALIGNED_ALLOC(3) page in the libbson manual πŸ’– this one is short and iconic, so let’s get into it.

✨ SYNOPSIS ✨

void *
bson_aligned_alloc (size_t alignment, size_t num_bytes);

πŸŽ€ PARAMETERS πŸŽ€

  • alignment β€” the alignment of the allocated bytes of memory. It must be a power of 2 and a multiple of sizeof (void *). Like, no cap, those are the rules bestie.
  • num_bytes β€” the number of bytes to allocate. It must be a multiple of alignment. Periodt.

🌸 DESCRIPTION 🌸

This is a portable aligned_alloc() wrapper. It’s giving convenience, but with rules.

If there was a failure to allocate num_bytes bytes aligned to alignment, the process will be aborted. Not a drill, bestie.

⚠️ WARNING: This function will abort on failure to allocate memory. Like, literally abort. πŸ’€

πŸ¦‹ RETURNS πŸ¦‹

A pointer to a memory region which HAS NOT been zeroed. Read that again, bestie: HAS NOT been zeroed. So don’t assume it’s all clean and zeroed out β€” it is not. πŸ™ˆ

πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc

2009-present, MongoDB, Inc.


okay that’s the whole page, bestie β€” mwah πŸ’‹ this libbson page is version 2.5.6, dated Oct 09, 2026. slay and stay aligned ✨

πŸ“¦ where this page comes from