acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
lv_tlsf.h (3674B)
1 #include "../lv_conf_internal.h" 2 #if LV_MEM_CUSTOM == 0 3 4 #ifndef LV_TLSF_H 5 #define LV_TLSF_H 6 7 /* 8 ** Two Level Segregated Fit memory allocator, version 3.1. 9 ** Written by Matthew Conte 10 ** http://tlsf.baisoku.org 11 ** 12 ** Based on the original documentation by Miguel Masmano: 13 ** http://www.gii.upv.es/tlsf/main/docs 14 ** 15 ** This implementation was written to the specification 16 ** of the document, therefore no GPL restrictions apply. 17 ** 18 ** Copyright (c) 2006-2016, Matthew Conte 19 ** All rights reserved. 20 ** 21 ** Redistribution and use in source and binary forms, with or without 22 ** modification, are permitted provided that the following conditions are met: 23 ** * Redistributions of source code must retain the above copyright 24 ** notice, this list of conditions and the following disclaimer. 25 ** * Redistributions in binary form must reproduce the above copyright 26 ** notice, this list of conditions and the following disclaimer in the 27 ** documentation and/or other materials provided with the distribution. 28 ** * Neither the name of the copyright holder nor the 29 ** names of its contributors may be used to endorse or promote products 30 ** derived from this software without specific prior written permission. 31 ** 32 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 33 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 34 ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 35 ** DISCLAIMED. IN NO EVENT SHALL MATTHEW CONTE BE LIABLE FOR ANY 36 ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 37 ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 38 ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 39 ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 40 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 41 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 */ 43 44 #include <stddef.h> 45 46 #if defined(__cplusplus) 47 extern "C" { 48 #endif 49 50 /* lv_tlsf_t: a TLSF structure. Can contain 1 to N pools. */ 51 /* lv_pool_t: a block of memory that TLSF can manage. */ 52 typedef void * lv_tlsf_t; 53 typedef void * lv_pool_t; 54 55 /* Create/destroy a memory pool. */ 56 lv_tlsf_t lv_tlsf_create(void * mem); 57 lv_tlsf_t lv_tlsf_create_with_pool(void * mem, size_t bytes); 58 void lv_tlsf_destroy(lv_tlsf_t tlsf); 59 lv_pool_t lv_tlsf_get_pool(lv_tlsf_t tlsf); 60 61 /* Add/remove memory pools. */ 62 lv_pool_t lv_tlsf_add_pool(lv_tlsf_t tlsf, void * mem, size_t bytes); 63 void lv_tlsf_remove_pool(lv_tlsf_t tlsf, lv_pool_t pool); 64 65 /* malloc/memalign/realloc/free replacements. */ 66 void * lv_tlsf_malloc(lv_tlsf_t tlsf, size_t bytes); 67 void * lv_tlsf_memalign(lv_tlsf_t tlsf, size_t align, size_t bytes); 68 void * lv_tlsf_realloc(lv_tlsf_t tlsf, void * ptr, size_t size); 69 void lv_tlsf_free(lv_tlsf_t tlsf, const void * ptr); 70 71 /* Returns internal block size, not original request size */ 72 size_t lv_tlsf_block_size(void * ptr); 73 74 /* Overheads/limits of internal structures. */ 75 size_t lv_tlsf_size(void); 76 size_t lv_tlsf_align_size(void); 77 size_t lv_tlsf_block_size_min(void); 78 size_t lv_tlsf_block_size_max(void); 79 size_t lv_tlsf_pool_overhead(void); 80 size_t lv_tlsf_alloc_overhead(void); 81 82 /* Debugging. */ 83 typedef void (*lv_tlsf_walker)(void * ptr, size_t size, int used, void * user); 84 void lv_tlsf_walk_pool(lv_pool_t pool, lv_tlsf_walker walker, void * user); 85 /* Returns nonzero if any internal consistency check fails. */ 86 int lv_tlsf_check(lv_tlsf_t tlsf); 87 int lv_tlsf_check_pool(lv_pool_t pool); 88 89 #if defined(__cplusplus) 90 }; 91 #endif 92 93 #endif /*LV_TLSF_H*/ 94 95 #endif /* LV_MEM_CUSTOM == 0 */