Subversion Repositories HelenOS-historic

Rev

Rev 195 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 195 Rev 374
Line 42... Line 42...
42
 */
42
 */
43
 
43
 
44
static chunk_t *chunk0;
44
static chunk_t *chunk0;
45
static spinlock_t heaplock;
45
static spinlock_t heaplock;
46
 
46
 
47
void heap_init(__address heap, size_t size)
47
void early_heap_init(__address heap, size_t size)
48
{
48
{
49
    spinlock_initialize(&heaplock);
49
    spinlock_initialize(&heaplock);
50
    memsetb(heap, size, 0);
50
    memsetb(heap, size, 0);
51
    chunk0 = (chunk_t *) heap;
51
    chunk0 = (chunk_t *) heap;
52
    chunk0->used = 0;
52
    chunk0->used = 0;
Line 56... Line 56...
56
}
56
}
57
 
57
 
58
/*
58
/*
59
 * Uses first-fit algorithm.
59
 * Uses first-fit algorithm.
60
 */
60
 */
61
void *malloc(size_t size)
61
void *early_malloc(size_t size)
62
{
62
{
63
    pri_t pri;
63
    pri_t pri;
64
    chunk_t *x, *y, *z;
64
    chunk_t *x, *y, *z;
65
 
65
 
66
    if (size == 0)
66
    if (size == 0)
Line 112... Line 112...
112
    spinlock_unlock(&heaplock);
112
    spinlock_unlock(&heaplock);
113
    cpu_priority_restore(pri);
113
    cpu_priority_restore(pri);
114
    return NULL;
114
    return NULL;
115
}
115
}
116
 
116
 
117
void free(void *ptr)
117
void early_free(void *ptr)
118
{
118
{
119
    pri_t pri;
119
    pri_t pri;
120
    chunk_t *x, *y, *z;
120
    chunk_t *x, *y, *z;
121
 
121
 
122
    if (!ptr)
122
    if (!ptr)