psl1ght
A free SDK for Sony's PS3 console
heap.h
Go to the documentation of this file.
1 
5 #ifndef __SYS_HEAP_H__
6 #define __SYS_HEAP_H__
7 
8 #include <ppu-types.h>
9 
10 #define HEAP_PREV_USED 1
11 #define HEAP_MIN_BLOCK_SIZE (sizeof(heap_block))
12 #define HEAP_BLOCK_HEADER_OFFSET (sizeof(u32))
13 #define HEAP_BLOCK_USER_OFFSET (sizeof(u32)*2)
14 #define HEAP_BLOCK_USED_OVERHEAD (HEAP_BLOCK_USER_OFFSET - HEAP_BLOCK_HEADER_OFFSET)
15 #define HEAP_OVERHEAD HEAP_BLOCK_USER_OFFSET
16 
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 typedef struct _heap_block_t heap_block;
24 {
25  u32 prev_size;
26  u32 size;
27  heap_block *next;
28  heap_block *prev;
29 };
30 
31 typedef struct _heap_cntrl_t
32 {
33  heap_block free_list;
34 
35  u32 page_size;
36  u32 min_block_size;
37 
38  void *begin;
39  void *end;
40 
41  heap_block *start;
42  heap_block *final;
43 
44  s32 lock;
45 } heap_cntrl;
46 
47 u32 heapInit(heap_cntrl *theheap,void *start_addr,u32 size);
48 void* heapAllocate(heap_cntrl *theheap,u32 size);
49 void* heapAllocateAligned(heap_cntrl *theheap,u32 size,u32 alignment);
50 bool heapFree(heap_cntrl *theheap,void *ptr);
51 
52 #ifdef __cplusplus
53  }
54 #endif
55 
56 #endif
Definition: heap.h:23
Definition: heap.h:31