31 lines
1.0 KiB
C
31 lines
1.0 KiB
C
#ifndef VLIBC_INTERNAL_MALLOC_H
|
|
#define VLIBC_INTERNAL_MALLOC_H
|
|
|
|
/*
|
|
* vlibc — internal allocator seam (todo 8).
|
|
*
|
|
* The allocator todo (#7) owns the real implementation and provides these
|
|
* entry points; library code that must allocate (strdup, strndup, and later
|
|
* stdio/regex/...) calls them instead of the public malloc/free so that the
|
|
* allocator remains the single allocation implementation. The public
|
|
* malloc/free/calloc/realloc of todo 7 must be backed by the same allocator,
|
|
* so a block returned by __libc_malloc can be released with public free.
|
|
*
|
|
* - __libc_malloc(n): allocate n bytes, 16-byte aligned; NULL + errno ENOMEM
|
|
* on failure. May return a unique pointer even when n == 0.
|
|
* - __libc_free(p): release a block returned by __libc_malloc; NULL is a
|
|
* no-op.
|
|
*/
|
|
|
|
#include <stddef.h>
|
|
|
|
#include "libc.h"
|
|
|
|
hidden void *
|
|
__libc_malloc(size_t n); // NOLINT(bugprone-reserved-identifier)
|
|
|
|
hidden void
|
|
__libc_free(void *p); // NOLINT(bugprone-reserved-identifier)
|
|
|
|
#endif /* VLIBC_INTERNAL_MALLOC_H */
|