struct vm_map_entry *tmpent = newents;
vm_map_entry_t tmpent = newents;
uvm_map_replace(map, start, end, newents, nnewents)	struct vm_map *map;	vaddr_t start, end;	struct vm_map_entry *newents;	int nnewents;{	struct vm_map_entry *oldent, *last;	/*	 * first find the blank map entry at the specified address	 */	if (!uvm_map_lookup_entry(map, start, &oldent)) {		return(FALSE);	}	/*	 * check to make sure we have a proper blank entry	 */	if (oldent->start != start || oldent->end != end ||	    oldent->object.uvm_obj != NULL || oldent->aref.ar_amap != NULL) {		return (FALSE);	}#ifdef DIAGNOSTIC	/*	 * sanity check the newents chain	 */	{		struct vm_map_entry *tmpent = newents;		int nent = 0;		vaddr_t cur = start;		while (tmpent) {			nent++;			if (tmpent->start < cur)				panic("uvm_map_replace1");			if (tmpent->start > tmpent->end || tmpent->end > end) {		printf("tmpent->start=0x%lx, tmpent->end=0x%lx, end=0x%lx\n",			    tmpent->start, tmpent->end, end);				panic("uvm_map_replace2");			}			cur = tmpent->end;			if (tmpent->next) {				if (tmpent->next->prev != tmpent)					panic("uvm_map_replace3");			} else {				if (newents->prev != tmpent)					panic("uvm_map_replace4");			}			tmpent = tmpent->next;		}		if (nent != nnewents)			panic("uvm_map_replace5");	}#endif	/*	 * map entry is a valid blank!   replace it.   (this does all the	 * work of map entry link/unlink...).	 */	if (newents) {		last = newents->prev;		/* critical: flush stale hints out of map */		SAVE_HINT(map, map->hint, newents);		if (map->first_free == oldent)			map->first_free = last;		last->next = oldent->next;		last->next->prev = last;		newents->prev = oldent->prev;		newents->prev->next = newents;		map->nentries = map->nentries + (nnewents - 1);	} else {		/* critical: flush stale hints out of map */		SAVE_HINT(map, map->hint, oldent->prev);		if (map->first_free == oldent)			map->first_free = oldent->prev;		/* NULL list of new entries: just remove the old one */		uvm_map_entry_unlink(map, oldent);	}	/*	 * now we can free the old blank entry, unlock the map and return.	 */	uvm_mapent_free(oldent);	return(TRUE);}