Subversion Repositories freemyipod

Rev

Go to most recent revision | 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;
625 theseven 34
void* tlsf_realign(tlsf_pool pool, void* ptr, size_t align, size_t size) ICODE_ATTR;
125 theseven 35
void* tlsf_realloc(tlsf_pool pool, void* ptr, size_t size) ICODE_ATTR;
36
void tlsf_free(tlsf_pool pool, void* ptr) ICODE_ATTR;
37
 
38
/* Debugging. */
39
typedef void (*tlsf_walker)(void* ptr, size_t size, int used, void* user);
40
void tlsf_walk_heap(tlsf_pool pool, tlsf_walker walker, void* user);
41
/* Returns nonzero if heap check fails. */
42
int tlsf_check_heap(tlsf_pool pool);
43
 
44
/* Returns internal block size, not original request size */
45
size_t tlsf_block_size(void* ptr) ICODE_ATTR;
46
 
47
/* Overhead of per-pool internal structures. */
48
size_t tlsf_overhead() ICODE_ATTR;
49
 
50
#if defined(__cplusplus)
51
};
52
#endif
53
 
54
#endif