-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlanzalloc.h
62 lines (53 loc) · 1.6 KB
/
lanzalloc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef __LANZALLOC_H__
#define __LANZALLOC_H__
typedef unsigned int lanzalloc_size_t;
struct lanzalloc;
// Initialize lanzalloc
/*
parameters:
void* memory: The memory head address you want to use for lanzalloc.
unsigned int size: The size of the memory.
unsigned int maxunit: The maximum number of memory units that lanzalloc can maintain.
return:
Return a lanzalloc pointer if initialize successfully, or return NULL.
*/
struct lanzalloc* lanzalloc_initialize(void* memory, lanzalloc_size_t size, lanzalloc_size_t maxunit);
// Alloc
/*
parameters:
struct lanzalloc* lanzalloc: Memory will be allocated from it.
unsigned int size: The size you want to allocate.
return:
Return a pointer if alloc successfully, or return NULL.
*/
void* lanzalloc_alloc(struct lanzalloc* lanzalloc, lanzalloc_size_t size);
// Realloc
/*
parameters:
struct lanzalloc* lanzalloc: Memory will be reallocated from it.
void* address: Memory to be operated on.
unsigned int newSize: The newsize you want to reallocate.
return:
Return a pointer if alloc successfully, or return NULL.
*/
void* lanzalloc_realloc(struct lanzalloc* lanzalloc, void* address, lanzalloc_size_t new_size);
// Free
/*
parameters:
struct lanzalloc* lanzalloc: Memory will be free from it.
void* address: Memory to be operated on.
*/
void lanzalloc_free(struct lanzalloc* lanzalloc, void* address);
// Free memory
/*
return:
Return the size of free memory.
*/
lanzalloc_size_t lanzalloc_freemem(struct lanzalloc* lanzalloc);
// Used memory
/*
return:
Return the size of used memory.
*/
lanzalloc_size_t lanzalloc_usedmem(struct lanzalloc* lanzalloc);
#endif