feature (kernel): Implemented 'bitmap_init'
This commit is contained in:
parent
630c2e9762
commit
ecf881967d
|
@ -499,10 +499,10 @@ The size is the size of the buffer in bytes, to get the amount of storable bits
|
|||
#### `bitmap_init_from_buffer(buffer, size)` - function (bitmap_T)
|
||||
Creates a bitmap object from a given buffer and size
|
||||
|
||||
#### `bitmap_init(size)` - function (bitmap_T) [NOT IMPLEMENTED YET]
|
||||
#### `bitmap_init(size)` - function (bitmap_T)
|
||||
Allocates memory to hold a bitmap in the given size and returns a `bitmap_T` with that buffer and size.
|
||||
|
||||
#### `bitmap_destruct(bitmap*)` - function (void) [NOT IMPLEMENTED YET]
|
||||
#### `bitmap_destruct(bitmap*)` - function (void)
|
||||
Frees the memory of the given bitmap created with `bitmap_init`.
|
||||
|
||||
#### `bitmap_set(bitmap*, index, value)` - function (bool)
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
#include "utils/bitmap.h"
|
||||
#include "utils/memory.h"
|
||||
|
||||
bitmap_T bitmap_init_from_buffer(void* buffer, uint32_t size) {
|
||||
bitmap_T bitmap;
|
||||
|
@ -23,11 +24,14 @@ bitmap_T bitmap_init_from_buffer(void* buffer, uint32_t size) {
|
|||
}
|
||||
|
||||
bitmap_T bitmap_init(uint32_t size) {
|
||||
// TODO: implement bitmap malloc constructor
|
||||
bitmap_T bitmap;
|
||||
bitmap.size = size / 8 + 1;
|
||||
bitmap.buffer = memory_allocate(bitmap.size);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
void bitmap_destruct(bitmap_T* bitmap) {
|
||||
|
||||
memory_free(bitmap->buffer);
|
||||
}
|
||||
|
||||
bool bitmap_set(bitmap_T* bitmap, uint32_t index, bool value) {
|
||||
|
|
Loading…
Reference in New Issue