/* subr_rmap.c 3.1 %H% */
* 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.
for (bp
=mp
; bp
->m_size
; bp
++) {
if (bp
->m_size
>= 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
);