KMALLOC(3)
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:
kasprintfkcallockmallockreallockreallocarraykstrdupkvasprintf
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
- Copyright (c) 2014, 2017 Kristaps Dzonsons <kristaps@bsd.lv>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms