/** * \file */ #include #include #include #include #define MAX_BLOCKS 512 //!< Maximum number of blocks that can be used /** * Represents a contiguos block in the heap */ typedef struct { char* bitmap; //!< Bitmap of avilable four byte groups size_t bitmap_byt_size; //!< Size of the bitmap in bytes size_t bitmap_bit_size; //!< Size of the bitmap in bits size_t avail_data_size; //!< Size of the data block void* data_block; //!< Data block } heap_block; static heap_block entries[MAX_BLOCKS]; //!< List of blocks in the heap static size_t num_used_entries=0; //!< Number of blocks in the heap /** * Get a bit in a bitmap * \param bmap The bitmap * \param index The index in the bitmap * \return the bit */ static char get_bmap_bit(char* bmap,size_t index) { size_t byte=index/8; size_t bit=index%8; char entry=bmap[byte]; return (entry&(1<0; } /** * Set a bit in a bitmap * \param bmap The bitmap * \param index The index in the bitmap */ static void set_bmap_bit(char* bmap,size_t index) { size_t byte=index/8; size_t bit=index%8; bmap[byte]=bmap[byte]|(1<=size) { char* bmap=entry.bitmap; size_t bmap_byt_sz=entry.bitmap_byt_size; for(size_t i=0;i