void allocator_destroy (struct allocator *a) { ASSERT (a != NULL); ASSERT (bitmap_none (a->used_map, 0, bitmap_size (a->used_map))); size_t pages = (bitmap_size (a->used_map)*a->item_size + PGSIZE-1) / PGSIZE; palloc_free_multiple (a->items, pages); bitmap_destroy (a->used_map); }
// ------------------------------------------------ void inode_free_all(void){ //go through buffer cache, write back the sectors belong to inode int i = 0; for (; i < BUFFER_SIZE; i++) { if (buffer_info_array[i].dirty) { //if (buffer_info_array[i].sector_num != -2 || buffer_info_array[i].buffer_inode != NULL) { if (buffer_info_array[i].sector_num != -2) { int sector_idx = buffer_info_array[i].sector_num; void *buffer_cache_start_addr = buffer_vaddr + i * BLOCK_SECTOR_SIZE; block_write (fs_device, sector_idx, buffer_cache_start_addr); buffer_info_array[i].sector_num = -2; buffer_info_array[i].buffer_inode = NULL; buffer_info_array[i].dirty = false; buffer_info_array[i].recentlyUsed = false; } } } palloc_free_multiple(buffer_vaddr,8); }
/* Frees the page at PAGE. */ void palloc_free_page (void *page) { palloc_free_multiple (page, 1); }