Rev 68 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 68 | Rev 72 | ||
---|---|---|---|
Line 40... | Line 40... | ||
40 | */ |
40 | */ |
41 | 41 | ||
42 | static chunk_t *chunk0; |
42 | static chunk_t *chunk0; |
43 | static spinlock_t heaplock; |
43 | static spinlock_t heaplock; |
44 | 44 | ||
45 | void heap_init(__address heap, int size) |
45 | void heap_init(__address heap, __u32 size) |
46 | { |
46 | { |
47 | spinlock_initialize(&heaplock); |
47 | spinlock_initialize(&heaplock); |
48 | memsetb(heap,size,0); |
48 | memsetb(heap, size, 0); |
49 | chunk0 = (chunk_t *) heap; |
49 | chunk0 = (chunk_t *) heap; |
50 | chunk0->used = 0; |
50 | chunk0->used = 0; |
51 | chunk0->size = size - sizeof(chunk_t); |
51 | chunk0->size = size - sizeof(chunk_t); |
52 | chunk0->next = NULL; |
52 | chunk0->next = NULL; |
53 | chunk0->prev = NULL; |
53 | chunk0->prev = NULL; |
54 | } |
54 | } |
55 | 55 | ||
56 | /* |
56 | /* |
57 | * Uses first-fit algorithm. |
57 | * Uses first-fit algorithm. |
58 | */ |
58 | */ |
59 | void *malloc(int size) |
59 | void *malloc(size_t size) |
60 | { |
60 | { |
61 | pri_t pri; |
61 | pri_t pri; |
62 | chunk_t *x, *y, *z; |
62 | chunk_t *x, *y, *z; |
63 | 63 | ||
64 | if (size == 0) |
64 | if (size == 0) |