/src/memory/tlsf/tlsf.h
https://bitbucket.org/vivkin/gam3b00bs/ · C Header · 69 lines · 23 code · 13 blank · 33 comment · 0 complexity · 0215ea5ec3dfb216ccc320847fc04a5c MD5 · raw file
- #ifndef INCLUDED_tlsf
- #define INCLUDED_tlsf
-
- /// @addtogroup MemorySubsystem
- /// @{
-
- /*
- ** Two Level Segregated Fit memory allocator, version 1.9.
- ** Written by Matthew Conte, and placed in the Public Domain.
- ** http://tlsf.baisoku.org
- **
- ** Based on the original documentation by Miguel Masmano:
- ** http://rtportal.upv.es/rtmalloc/allocators/tlsf/index.shtml
- **
- ** Please see the accompanying Readme.txt for implementation
- ** notes and caveats.
- **
- ** This implementation was written to the specification
- ** of the document, therefore no GPL restrictions apply.
- */
-
- #include <stddef.h>
-
- #if defined(__cplusplus)
- extern "C" {
- #endif
-
- /* Create/destroy a memory pool. */
- /// Type of TLSF pool
- typedef void* tlsf_pool;
- /// Create TLSF pool on chunk of memory
- tlsf_pool tlsf_create(void* mem, size_t bytes);
- /// Destroy TLSF pool
- /// @note You should destroy underlying block yourself.
- void tlsf_destroy(tlsf_pool pool);
-
- /* malloc/memalign/realloc/free replacements. */
- /// Allocate block
- void* tlsf_malloc(tlsf_pool pool, size_t bytes);
- /// Allocate aligned block
- void* tlsf_memalign(tlsf_pool pool, size_t align, size_t bytes);
- /// Realloc block
- void* tlsf_realloc(tlsf_pool pool, void* ptr, size_t size);
- /// Free block
- void tlsf_free(tlsf_pool pool, void* ptr);
-
- /* Debugging. */
- typedef void (*tlsf_walker)(void* ptr, size_t size, int used, void* user);
- /// Heap walker
- void tlsf_walk_heap(tlsf_pool pool, tlsf_walker walker, void* user);
- /// Returns nonzero if heap check fails.
- int tlsf_check_heap(tlsf_pool pool);
-
- /// Returns internal block size, not original request size
- size_t tlsf_block_size(void* ptr);
-
- /// Overhead of per-pool internal structures.
- size_t tlsf_overhead();
-
- /// Get total size and free size
- void tlsf_statistics(tlsf_pool tlsf, size_t* total_size, size_t* free_size);
-
- #if defined(__cplusplus)
- };
- #endif
-
- /// @?
-
- #endif