BSON_ARRAY_ALLOC(3)
π BSON_ARRAY_ALLOC(3) β the libbson glow-up
okay bestie, so this is a libbson page, and it's genuinely one of the shortest and sweetest ones β it's literally just "we made malloc() portable and also it will Not hesitate to end your whole process" π«Ά so let's get into it β¨
β¨ SYNOPSIS β¨
#define BSON_ARRAY_ALLOC(Count, Type) \
(Type*) bson_array_alloc (Count, sizeof (Type))
void *
bson_array_alloc (size_t num_elems, size_t elem_size);
so there's the macro (she's giving convenience π ) and there's the actual function underneath her. two icons, one vibe π
π PARAMETERS π
num_elemsβ asize_tholding the number of objects to allocate. like, how many of the thing do you want. that many πΈelem_sizeβ asize_tholding the size of each object in bytes. how chunky is each one π
π DESCRIPTION π
this is a portable malloc() wrapper that allocates an array of objects. that's the whole pitch, and honestly? she ate. β¨
now here's the part where you sit up straight, because: if num_elems * elem_size cannot be represented in a size_t, or if there was a failure to allocate num_elems * elem_size bytes, the process will be aborted. π like, not "return NULL and let you handle it" β the process is done. main character exit, no encore π
β οΈ WARNING: this function will abort on failure to allocate memory. no cap, no graceful degradation, just vibes and termination. plan accordingly bestie π
β RETURNS β
a pointer to a memory region which HAS NOT been zeroed. read that again. HAS NOT. it's not clean, it's not fresh, it's not a blank slate β if you want zeroes you're gonna have to put them there yourself π§
lowkey this is the classic malloc behaviour, she's just being very clear about it so nobody comes for her later π
π AUTHOR π
MongoDB, Inc
π COPYRIGHT π
2009-present, MongoDB, Inc.
so yeah, that's the whole page, short and iconic π¦ libbson version 2.5.6, dated Oct 09, 2026 β mwah, that's the sign-off, go forth and allocate responsibly and maybe check your multiplication first bestie ππ
π¦ where this page comes from
- epel 10: libbson-devel 2.5.6-1.el10_3 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms