/* Bitmap management The bitmap should be an array of unsigned char. */ // Used by test harness long get_index(void *ptr); // Utility function to print out an array of char as bits // Print the entire bitmap. Arguments: The bitmap itself, and the length of the // bitmap Each bit of the bitmap represents 1 byte of memory. 0 = free, 1 = // allocated. map: The bitmap itself, an array of unsigned char. // Each bit of the bitmap represents one byte of memory // len: The length of the bitmap array in characters // // Returns: Nothing void print_map(unsigned char *map, int len); // Search the bitmap for the required number of zeroes (representing // free bytes of memory). Returns index of first stretch of 0s // that meet the criteria. You can use this as an index into // an array of char that represents the process heap // bitmap = Bitmap declared as an array of unsigned char // len = Length of bitmap in characters // num_zeroes = Length of string of 0's required // Returns: Index to stretch of 0's of required length long search_map(unsigned char *bitmap, int len, long num_zeroes); // Marks a stretch of bits as "1", representing allocated memory // map = Bitmap declared as array of unsigned char // start = Starting index to mark // length = Number of bits to mark as "1" void allocate_map(unsigned char *map, long start, long length); // Marks a stretch of bits as "0", representing allocated memory // map = Bitmap declared as array of unsigned char // start = Starting index to mark // length = Number of bits to mark as "0" void free_map(unsigned char *, long, long);