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 Β© 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