CVSROOT:        /cvs
Module name:    src
Changes by:     [email protected] 2025/12/11 05:18:27

Modified files:
        usr.sbin/bgpd  : Makefile bgpd.h 
Added files:
        usr.sbin/bgpd  : bitmap.c 

Log message:
Introduce a bitmap API that scales dynamically up but is also minimal for
the common case.

Functions include:
- set, test, clear: set, test and clear a bit in the map
- empty: check if a bitmap is empty (has no bit set).
- id_get: return the lowest free id in map
- id_put: return an id to the map, aka clear
- init, reset: initialize and free a map

The first 127 elements are put directly into struct bitmap without further
allocation. For maps with more than 127 elements external memory is allocated
in the set function. This memory is only freed by reset which must be called
before an object is removed containing a bitmap.
It is not possible to set bit 0 of a bitmap since that bit is used to
differentiate between access modes. In my use cases this is perfectly fine
since most code already treats 0 in a special way.

OK tb@

Reply via email to