// SPDX-License-Identifier: GPL-3.0-or-later #ifndef VCC_COMPAT_STDLIB_H #define VCC_COMPAT_STDLIB_H #include // stddef.h has already included cmoc.h. Replace its decimal-only macros in // this opt-in header, leaving the explicitly named CMOC routines available. #undef strtol #undef strtoul long strtol(const char *text, char **endptr, int base); unsigned long strtoul(const char *text, char **endptr, int base); // Supply a writable guest array (at least 16 bytes) that stays at the same // address for the lifetime of the heap. Its one-past-end address must fit in // 16 bits. Return 1 on success or 0 if invalid or any allocation is live. // A rejected initialization leaves the current heap and its contents intact. int vcc_heap_init(void *buffer, size_t capacity); // Zero-size requests return NULL. Allocation can also fail before initialization // or when no contiguous block fits. calloc checks for multiplication overflow. void *malloc(size_t size); void *calloc(size_t count, size_t size); // Growth may move the block. If it fails, the old allocation stays valid. // Shrinking keeps the existing block. realloc(ptr, 0) releases it. void *realloc(void *ptr, size_t size); // Accepts NULL or a live pointer returned by this heap. void free(void *ptr); #endif