1/* 2 * Copyright 2016, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 8 * See "LICENSE_BSD2.txt" for details. 9 * 10 * @TAG(D61_BSD) 11 */ 12 13#ifndef _CBITMAPALLOCPOOL_H_ 14#define _CBITMAPALLOCPOOL_H_ 15 16#include <stdbool.h> 17#include <data_struct/cvector.h> 18 19#define CBPOOL_INVALID ((uint32_t) (-1)) 20 21typedef struct cbpool_s { 22 uint32_t size; 23 uint32_t size_ntiles; 24 uint32_t *bitmap; 25} cbpool_t; 26 27void cbpool_init(cbpool_t *p, uint32_t size); 28 29void cbpool_init_static(cbpool_t *p, uint32_t size, char *buffer, int bufferSize); 30 31void cbpool_release(cbpool_t *p); 32 33uint32_t cbpool_alloc(cbpool_t *p, uint32_t size); 34 35void cbpool_free(cbpool_t *p, uint32_t obj, uint32_t size); 36 37bool cbpool_check_single(cbpool_t *p, uint32_t obj); 38 39void cbpool_set_single(cbpool_t *p, uint32_t obj, bool val); 40 41#endif /* _CBITMAPALLOCPOOL_H_ */ 42