From 434ddcd907832b1febc7d70e4faa52109c7eb3bd Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Wed, 7 Oct 2026 17:37:26 -0400 Subject: add memory region object for better memory managment --- lib/bitmap.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/bitmap.h (limited to 'lib/bitmap.h') diff --git a/lib/bitmap.h b/lib/bitmap.h new file mode 100644 index 0000000..db9653a --- /dev/null +++ b/lib/bitmap.h @@ -0,0 +1,25 @@ +#ifndef _JOVE_LIB_BITMAP_H +#define _JOVE_LIB_BITMAP_H 1 + +#include +#include + +typedef unsigned char bitmap_block_t; +#define BITMAP_BLOCK_BITS (sizeof(bitmap_block_t) * 8) + +struct bitmap +{ + unsigned int total_bits; + unsigned int free_bits; + unsigned int last_free_bit; + bitmap_block_t data[]; +}; + +extern bool bitmap_check(struct bitmap *bitmap, size_t idx); +extern void bitmap_set(struct bitmap *bitmap, size_t idx); +extern void bitmap_unset(struct bitmap *bitmap, size_t idx); + +int bitmap_findfree(struct bitmap *bitmap); +int bitmap_findfree_contig(struct bitmap *bitmap, size_t size); + +#endif -- cgit v1.2.3