KMALLOC(3) Library Functions Manual KMALLOC(3)

kasprintf, kcalloc, kmalloc, krealloc, kreallocarray, kstrdup, kvasprintfmemory allocation functions for kcgi

library “libkcgi”

#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);

These functions wrap around corresponding libc versions except that on allocation failure, they print a warning message to standard error output and call exit(3).

Calling (), (), (), or () with sz or nm equal to zero, or passing NULL to (), additionally prints a warning message to the standard error output and produces non-portable results.

kcgi(3)

These functions were written by Kristaps Dzonsons <kristaps@bsd.lv>.

December 2, 2023 OpenBSD 7.4