All pastes #946966 Raw Edit

Unnamed

public text v1 · immutable
·published 2008-03-18 01:57 UTC
rendered paste body
#ifndef LARDALLOC_H_INCLUDED
#define LARDALLOC_H_INCLUDED
#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#define HEADER_SIZE sizeof(lardbuffer)
#define LARD_PTR unsigned short
#define MIN(a,b) a<b?a:b


/*
*  block size, and the short pointer to the first free block
*/

typedef struct lardbuffer {
    unsigned int size;
    unsigned short first_free;
} lardbuffer;

lardbuffer * initialize_buffer(unsigned int size, unsigned int maxelements);
void * allocate(lardbuffer *b);
void lardfree(lardbuffer *b, void * ptr);
LARD_PTR deref(lardbuffer *b, LARD_PTR ptr);
#endif // LARDALLOC_H_INCLUDED