2020-07-26 15:38:29 -05:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
*/
|
|
|
|
|
2020-07-26 14:39:08 -05:00
|
|
|
#ifndef STDLIB_H
|
|
|
|
#define STDLIB_H
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2020-07-26 15:38:29 -05:00
|
|
|
#define EXIT_SUCCESS 0 //!< Success exit code
|
|
|
|
#define EXIT_FAILURE 1 //!< Failure exit code
|
2020-07-26 14:39:08 -05:00
|
|
|
|
2020-07-26 15:38:29 -05:00
|
|
|
/**
|
|
|
|
* Allocates a block of memory on the heap
|
|
|
|
* \param size The size of the block to allocate
|
|
|
|
* \return The address of the allocated block, or NUL if the allocation failed
|
|
|
|
*/
|
2020-07-26 14:39:08 -05:00
|
|
|
void* malloc(size_t size);
|
2020-07-26 15:38:29 -05:00
|
|
|
/**
|
|
|
|
* Changes a block of memory on the heap to a new size, or if mem is NULL, act like malloc
|
|
|
|
* \param mem The block of memory to change size
|
|
|
|
* \param new_sz The size of the block to allocate
|
|
|
|
* \return The new address of the allocated block, or NUL if the allocation failed
|
|
|
|
*/
|
2020-07-26 14:39:08 -05:00
|
|
|
void* realloc(void *mem, size_t new_sz);
|
2020-07-26 15:38:29 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Frees a block of memory on the heap
|
|
|
|
* \param mem The block of memory to free
|
|
|
|
*/
|
2020-07-26 14:39:08 -05:00
|
|
|
void free(void* mem);
|
2020-07-26 15:38:29 -05:00
|
|
|
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
2020-07-26 14:39:08 -05:00
|
|
|
void abort(void); // GCC required
|
|
|
|
int atexit(void (*func)(void)); // GCC required
|
|
|
|
int atoi(const char *str); // GCC required
|
|
|
|
char *getenv(const char *name); // GCC required
|
2020-07-26 15:38:29 -05:00
|
|
|
#endif
|
|
|
|
/**
|
|
|
|
* Exit the process
|
|
|
|
* \param code The exit code of the process
|
|
|
|
*/
|
2020-07-26 14:39:08 -05:00
|
|
|
__attribute__((noreturn)) void exit(int code);
|
|
|
|
|
|
|
|
#endif
|