Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
125 theseven 1
#ifndef INCLUDED_tlsf
2
#define INCLUDED_tlsf
3
 
4
/*
5
** Two Level Segregated Fit memory allocator, version 1.9.
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
11
**
12
** Please see the accompanying Readme.txt for implementation
13
** notes and caveats.
14
**
15
** This implementation was written to the specification
16
** of the document, therefore no GPL restrictions apply.
17
*/
18
 
19
#include "../../global.h"
20
#include <stddef.h>
21
 
22
#if defined(__cplusplus)
23
extern "C" {
24
#endif
25
 
26
/* Create/destroy a memory pool. */
27
typedef void* tlsf_pool;
28
tlsf_pool tlsf_create(void* mem, size_t bytes);
29
void tlsf_destroy(tlsf_pool pool);
30
 
31
/* malloc/memalign/realloc/free replacements. */
32
void* tlsf_malloc(tlsf_pool pool, size_t bytes) ICODE_ATTR;
33
void* tlsf_memalign(tlsf_pool pool, size_t align, size_t bytes) ICODE_ATTR;
34
void* tlsf_realloc(tlsf_pool pool, void* ptr, size_t size) ICODE_ATTR;
35
void tlsf_free(tlsf_pool pool, void* ptr) ICODE_ATTR;
36
 
37
/* Debugging. */
38
typedef void (*tlsf_walker)(void* ptr, size_t size, int used, void* user);
39
void tlsf_walk_heap(tlsf_pool pool, tlsf_walker walker, void* user);
40
/* Returns nonzero if heap check fails. */
41
int tlsf_check_heap(tlsf_pool pool);
42
 
43
/* Returns internal block size, not original request size */
44
size_t tlsf_block_size(void* ptr) ICODE_ATTR;
45
 
46
/* Overhead of per-pool internal structures. */
47
size_t tlsf_overhead() ICODE_ATTR;
48
 
49
#if defined(__cplusplus)
50
};
51
#endif
52
 
53
#endif