2 * Copyright 2009 Colin Günther, coling@gmx.de
3 * All Rights Reserved. Distributed under the terms of the MIT License.
8 /*! Wrapper functions for accessing the number buffer.*/
13 #include <util/RadixBitmap.h>
16 #define ID_STORE_FULL -1
20 _new_unrhdr_buffer(struct unrhdr
* idStore
, uint32 maxIdCount
)
22 status_t status
= B_OK
;
24 idStore
->idBuffer
= radix_bitmap_create(maxIdCount
);
25 if (idStore
->idBuffer
== NULL
)
33 _delete_unrhdr_buffer_locked(struct unrhdr
* idStore
)
35 radix_bitmap_destroy(idStore
->idBuffer
);
40 _alloc_unr_locked(struct unrhdr
* idStore
)
42 radix_slot_t slotIndex
;
43 int id
= ID_STORE_FULL
;
45 slotIndex
= radix_bitmap_alloc(idStore
->idBuffer
, 1);
46 if (slotIndex
!= RADIX_SLOT_NONE
)
47 id
= slotIndex
+ idStore
->idBias
;
54 _free_unr_locked(struct unrhdr
* idStore
, u_int identity
)
56 uint32 slotIndex
= (int32
)identity
- idStore
->idBias
;
58 radix_bitmap_dealloc(idStore
->idBuffer
, slotIndex
, 1);