NE_MALLOC(3)
π NAME π
Okay so this is NE_MALLOC(3) from the neon API reference, and it's all about the memory allocation wrapper besties: ne_malloc, ne_calloc, ne_realloc, ne_strdup, ne_strndup, and ne_oom_callback. The whole squad, no cap. π
β¨ SYNOPSIS β¨
#include <ne_alloc.h>
void *ne_malloc(size_t size);
void *ne_calloc(size_t size);
void *ne_realloc(void *size, size_t len);
char *ne_strdup(const char *s);
char *ne_strndup(const char *s, size_t size);
void ne_oom_callback(void (*callback)(void));
π«Ά DESCRIPTION π«Ά
So ne_malloc, ne_calloc, ne_realloc, ne_strdup, and ne_strdnup β and yes bestie, the page literally says ne_strdnup right there in this sentence, I'm not editing the typo out β provide wrappers for the equivalent functions in the standard C library. Iconic, but with a bonus guarantee. β¨
The extra guarantee is this: if the C library equivalent returns NULL when no memory is available, then an optional callback will be called, and the library will then call abort(). So it's not quietly returning NULL and letting you figure it out β it's giving "we are so done here" energy. π
ne_oom_callback registers a callback which will be invoked if an out of memory error is detected. That's it, that's the whole job. π
π¦ NOTES π¦
okay, important vibe check: if the operating system uses optimistic memory allocation, then the C library memory allocation routines will not return NULL. Which means it is not possible to gracefully handle memory allocation failures. Not me being dramatic, that's literally what the page says. π
πΈ COPYRIGHT πΈ
Copyright Β© 2001-2026 Joe Orton
cute sign-off time: this page comes from the neon source/version, dated 03/20/2026, and it's NE_MALLOC(3) in the manual set. slay, bye bestie πβ¨π¦
π¦ where this page comes from
- arch rolling: neon 0.37.1-1 Β· LGPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms