result = vm_map_find(map, object, poffset, addr, size, anywhere);
start = *addr; vm_map_lock(map); if (anywhere) { again: if (vm_map_findspace(map, start, size, addr)) result = KERN_NO_SPACE; else { vm_object_prefer(object, poffset, addr); start = *addr; result = vm_map_insert(map, object, poffset, start, start + size); if (result == KERN_NO_SPACE) goto again; } } else result = vm_map_insert(map, object, poffset, start, start + size); vm_map_unlock(map);
vm_allocate_with_pager(map, addr, size, anywhere, pager, poffset, internal)	register vm_map_t	map;	register vm_offset_t	*addr;	register vm_size_t	size;	boolean_t		anywhere;	vm_pager_t		pager;	vm_offset_t		poffset;	boolean_t		internal;{	register vm_object_t	object;	register int		result;	if (map == NULL)		return(KERN_INVALID_ARGUMENT);	*addr = trunc_page(*addr);	size = round_page(size);	/*	 *	Lookup the pager/paging-space in the object cache.	 *	If it's not there, then create a new object and cache	 *	it.	 */	object = vm_object_lookup(pager);	cnt.v_lookups++;	if (object == NULL) {		object = vm_object_allocate(size);		/*		 * From Mike Hibler: "unnamed anonymous objects should never		 * be on the hash list ... For now you can just change		 * vm_allocate_with_pager to not do vm_object_enter if this		 * is an internal object ..."		 */		if (!internal)			vm_object_enter(object, pager);	} else		cnt.v_hits++;	if (internal)		object->flags |= OBJ_INTERNAL;	else {		object->flags &= ~OBJ_INTERNAL;		cnt.v_nzfod -= atop(size);	}	result = vm_map_find(map, object, poffset, addr, size, anywhere);	if (result != KERN_SUCCESS)		vm_object_deallocate(object);	else if (pager != NULL)		vm_object_setpager(object, pager, (vm_offset_t) 0, TRUE);	return(result);}