/* subr_rmap.c.sav 4.1 %G% */
* Allocate 'size' units from the given
* map. Return the base of the allocated
* In a map, the addresses are increasing and the
* list is terminated by a 0 size.
* The swap map unit is 512 bytes.
* Algorithm is first-fit.
if (size <= 0 || mp == swapmap && size > DMMAX)
for (bp=mp; bp->m_size; bp++) {
if (bp->m_size >= size) {
(first = DMMAX - bp->m_addr%DMMAX) < bp->m_size) {
if (bp->m_size - first < size)
rest = bp->m_size - first - size;
mfree(swapmap, rest, a+size);
if ((bp->m_size -= size) == 0) {
(bp-1)->m_addr = bp->m_addr;
} while ((bp-1)->m_size = bp->m_size);
if (mp == swapmap && a % CLSIZE)
* Free the previously allocated space aa
* of size units into the specified map.
* Sort aa into map and combine on
* one or both ends if possible.
for (; bp->m_addr<=a && bp->m_size!=0; bp++)
if (bp>mp && (bp-1)->m_addr+(bp-1)->m_size > a)
if (a+size > bp->m_addr && bp->m_size)
if (bp>mp && (bp-1)->m_addr+(bp-1)->m_size == a) {
if (a+size == bp->m_addr) {
(bp-1)->m_size += bp->m_size;
(bp-1)->m_addr = bp->m_addr;
(bp-1)->m_size = bp->m_size;
if (a+size == bp->m_addr && bp->m_size) {
if ((mp == kernelmap) && kmapwnt) {
wakeup((caddr_t)kernelmap);