FLTK-GUI: Correct Oscilgen win title for padsynth
[zynaddsubfx-code.git] / tlsf / tlsf.h
blob4bf32e01988ec9817076a5522b00c5936d565536
1 #ifndef INCLUDED_tlsf
2 #define INCLUDED_tlsf
4 /*
5 ** Two Level Segregated Fit memory allocator, version 3.0.
6 ** Written by Matthew Conte, and placed in the Public Domain.
7 ** http://tlsf.baisoku.org
8 **
9 ** Based on the original documentation by Miguel Masmano:
10 ** http://rtportal.upv.es/rtmalloc/allocators/tlsf/index.shtml
12 ** Please see the accompanying Readme.txt for implementation
13 ** notes and caveats.
15 ** This implementation was written to the specification
16 ** of the document, therefore no GPL restrictions apply.
19 #include <stddef.h>
21 #if defined(__cplusplus)
22 extern "C" {
23 #endif
25 /* tlsf_t: a TLSF structure. Can contain 1 to N pools. */
26 /* pool_t: a block of memory that TLSF can manage. */
27 typedef void* tlsf_t;
28 typedef void* pool_t;
30 /* Create/destroy a memory pool. */
31 tlsf_t tlsf_create(void* mem);
32 tlsf_t tlsf_create_with_pool(void* mem, size_t bytes);
33 void tlsf_destroy(tlsf_t tlsf);
34 pool_t tlsf_get_pool(tlsf_t tlsf);
36 /* Add/remove memory pools. */
37 pool_t tlsf_add_pool(tlsf_t tlsf, void* mem, size_t bytes);
38 void tlsf_remove_pool(tlsf_t tlsf, pool_t pool);
40 /* malloc/memalign/realloc/free replacements. */
41 void* tlsf_malloc(tlsf_t tlsf, size_t bytes);
42 void* tlsf_memalign(tlsf_t tlsf, size_t align, size_t bytes);
43 void* tlsf_realloc(tlsf_t tlsf, void* ptr, size_t size);
44 void tlsf_free(tlsf_t tlsf, void* ptr);
46 /* Returns internal block size, not original request size */
47 size_t tlsf_block_size(void* ptr);
49 /* Overheads/limits of internal structures. */
50 size_t tlsf_size();
51 size_t tlsf_align_size();
52 size_t tlsf_block_size_min();
53 size_t tlsf_block_size_max();
54 size_t tlsf_pool_overhead();
55 size_t tlsf_alloc_overhead();
57 /* Debugging. */
58 typedef void (*tlsf_walker)(void* ptr, size_t size, int used, void* user);
59 void tlsf_walk_pool(pool_t pool, tlsf_walker walker, void* user);
60 /* Returns nonzero if any internal consistency check fails. */
61 int tlsf_check(tlsf_t tlsf);
62 int tlsf_check_pool(pool_t pool);
64 /* TODO add utilities for
65 * - Find Unused Pool Chunks
66 * - Define if the pool is running low
69 #if defined(__cplusplus)
71 #endif
73 #endif