KMALLOC(3)

πŸ“¦
version 1.0.1 Β· 2 versions
, in alpine 3.24

KMALLOC(3) β€” but make it bestie ✨

okay so this is from the Library Functions Manual and it's literally all about memory allocation for kcgi. no cap, it's giving "I handle your malloc so you don't have to" energy. πŸŽ€


✨ NAME ✨

bestie, listen β€” these are the memory allocation functions for kcgi:

  • kasprintf
  • kcalloc
  • kmalloc
  • krealloc
  • kreallocarray
  • kstrdup
  • kvasprintf

they're all here to keep your memory game strong πŸ’ͺ


🌈 LIBRARY 🌈

you'll find these in the library β€œlibkcgi” β€” that's the one, periodt.


πŸ“š SYNOPSIS πŸ“š

#include <sys/types.h>
#include <stdarg.h>
#include <stdint.h>
#include <kcgi.h>

int
kasprintf(char **p, const char *fmt, ...);

void *
kcalloc(size_t nm, size_t sz);

void *
kmalloc(size_t sz);

void *
krealloc(void *p, size_t sz);

void *
kreallocarray(void *p, size_t nm, size_t sz);

char *
kstrdup(const char *cp);

int
kvasprintf(char **p, const char *fmt, va_list ap);

like, just look at that signature glow-up ✨


πŸ’– DESCRIPTION πŸ’–

so here's the tea: these functions are basically the libc versions but with main character energy. they wrap around the regular libc allocation functions, BUT β€” and this is the important part β€” if allocation fails, they print a warning message to standard error output and then call exit(3). like, they don't just return NULL and leave you hanging. they're dramatic and they will end the whole program. πŸ’€

⚠️ warning bestie: allocation failure means your program is done. no second chances, no "try again later." they said "exit(3)" and they meant it.

and there's more! calling kcalloc(), kmalloc(), krealloc(), or kreallocarray() with sz or nm equal to zero β€” or passing NULL to kstrdup() β€” will also print a warning message to standard error output and produce non-portable results. so like, don't do that. it's giving undefined behavior and we don't stan that here. πŸ™ˆ


πŸ‘€ SEE ALSO πŸ‘€

  • kcgi(3) β€” go read it, iykyk πŸ¦‹

πŸ‘‘ AUTHORS πŸ‘‘

these iconic functions were written by Kristaps Dzonsons <kristaps@bsd.lv>. absolute legend behavior fr fr. 🫢


alright bestie, that's the whole page! signing off with Debian vibes and $Mdocdate$ energy β€” you're gonna slay those allocations now, no cap πŸ’…βœ¨

πŸ“¦ where this page comes from
  • alpine 3.24: kcgi-doc 1.0.1-r0 Β· ISC
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms