diff options
Diffstat (limited to 'tinyalloc.h')
| -rw-r--r-- | tinyalloc.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tinyalloc.h b/tinyalloc.h new file mode 100644 index 0000000..73e2b74 --- /dev/null +++ b/tinyalloc.h @@ -0,0 +1,37 @@ +#include <stdbool.h> +#include <stddef.h> +#include <stdint.h> + +#ifndef TA_ALIGN +#define TA_ALIGN 8 +#endif + +#ifndef TA_BASE +#define TA_BASE 0x400 +#endif + +#ifndef TA_HEAP_START +#define TA_HEAP_START (TA_BASE + sizeof(Heap)) +#endif + +#ifndef TA_HEAP_LIMIT +#define TA_HEAP_LIMIT (1 << 24) +#endif + +#ifndef TA_HEAP_BLOCKS +#define TA_HEAP_BLOCKS 256 +#endif + +#ifndef TA_SIZE_THRESHOLD +#define TA_SIZE_THRESHOLD 16 +#endif + +bool ta_init(); +void *ta_alloc(size_t num); +void *ta_calloc(size_t num, size_t size); +bool ta_free(void *ptr); + +size_t ta_num_free(); +size_t ta_num_used(); +size_t ta_num_avail(); +bool ta_check(); |
