123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- #pragma once
- #include <assert.h>
- #include <limits.h>
- #include <stddef.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <stddef.h>
- #include "heap_tlsf_config.h"
- #if defined(__cplusplus)
- extern "C" {
- #endif
- #define tlsf_cast(t, exp) ((t) (exp))
- #define tlsf_min(a, b) ((a) < (b) ? (a) : (b))
- #define tlsf_max(a, b) ((a) > (b) ? (a) : (b))
- typedef ptrdiff_t tlsfptr_t;
- typedef struct block_header_t
- {
-
- struct block_header_t* prev_phys_block;
-
- size_t size;
-
- struct block_header_t* next_free;
- struct block_header_t* prev_free;
- } block_header_t;
- #include "heap_tlsf_block_functions.h"
- typedef void* tlsf_t;
- typedef void* pool_t;
- tlsf_t tlsf_create(void* mem, size_t max_bytes);
- tlsf_t tlsf_create_with_pool(void* mem, size_t pool_bytes, size_t max_bytes);
- pool_t tlsf_get_pool(tlsf_t tlsf);
- pool_t tlsf_add_pool(tlsf_t tlsf, void* mem, size_t bytes);
- void tlsf_remove_pool(tlsf_t tlsf, pool_t pool);
- void* tlsf_malloc(tlsf_t tlsf, size_t size);
- void* tlsf_memalign(tlsf_t tlsf, size_t align, size_t size);
- void* tlsf_memalign_offs(tlsf_t tlsf, size_t align, size_t size, size_t offset);
- void* tlsf_realloc(tlsf_t tlsf, void* ptr, size_t size);
- void tlsf_free(tlsf_t tlsf, void* ptr);
- size_t tlsf_block_size(void* ptr);
- size_t tlsf_size(tlsf_t tlsf);
- size_t tlsf_align_size(void);
- size_t tlsf_block_size_min(void);
- size_t tlsf_block_size_max(tlsf_t tlsf);
- size_t tlsf_pool_overhead(void);
- size_t tlsf_alloc_overhead(void);
- size_t tlsf_fit_size(tlsf_t tlsf, size_t size);
- typedef void (*tlsf_walker)(void* ptr, size_t size, int used, void* user);
- void tlsf_walk_pool(pool_t pool, tlsf_walker walker, void* user);
- int tlsf_check(tlsf_t tlsf);
- int tlsf_check_pool(pool_t pool);
- #if defined(__cplusplus)
- };
- #endif
|