rem: for (i = VADDR_TO_PDENT(USER_BASE); i < VADDR_TO_PDENT(USER_BASE + (USER_SIZE - 1)); i++) { addr pgtable_addr;
add: for (i = VADDR_TO_PDENT(USER_BASE); i <= VADDR_TO_PDENT(USER_BASE + (USER_SIZE - 1)); i++) { addr_t pgtable_addr;
context: destroy_tmap(vm_translation_map *map){	int state;	vm_translation_map *entry;	vm_translation_map *last = NULL;	unsigned int i;	if (map == NULL)		return;	// remove it from the tmap list	state = disable_interrupts();	acquire_spinlock(&tmap_list_lock);	entry = tmap_list;	while (entry != NULL) {		if (entry == map) {			if (last != NULL)				last->next = entry->next;			else				tmap_list = entry->next;			break;		}		last = entry;		entry = entry->next;	}	release_spinlock(&tmap_list_lock);	restore_interrupts(state);	if (map->arch_data->pgdir_virt != NULL) {		// cycle through and free all of the user space pgtables		for (i = VADDR_TO_PDENT(USER_BASE); i < VADDR_TO_PDENT(USER_BASE + (USER_SIZE - 1)); i++) {			addr pgtable_addr;			vm_page *page;			if (map->arch_data->pgdir_virt[i].present == 1) {				pgtable_addr = map->arch_data->pgdir_virt[i].addr;				page = vm_lookup_page(pgtable_addr);				if (!page)					panic("destroy_tmap: didn't find pgtable page\n");				vm_page_set_state(page, PAGE_STATE_FREE);			}		}		free(map->arch_data->pgdir_virt);	}	free(map->arch_data);	recursive_lock_destroy(&map->lock);}