Example #1
0
void *pmalloc(mem_pool_t *pool, size_t size)
{
    u_char           *p;
    mem_pool_chunk_t *chunk;

    if (size <= pool->max) {
        chunk = pool->current;

        do {
            p = chunk->last;
            if ((u_char *) chunk->end - p >= size) {
                chunk->last += size;
                return p;
            }

            chunk = chunk->next;
        } while (chunk);

        return add_mem_chunk(pool, size);
    } 

    return alloc_large_mem(pool, size);
}
Example #2
0
void kfree(void *mem)
{
    alloc_control_data *d = (alloc_control_data *)((uint32_t)mem - ALLOC_CONTROL_SIZE);
    
    add_mem_chunk(d, d->real_size);
}