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 _CALLOCPOOL_H_ 14#define _CALLOCPOOL_H_ 15 16#include <stdbool.h> 17#include <data_struct/cvector.h> 18 19typedef struct cpool_s { 20 uint32_t start; 21 uint32_t end; 22 uint32_t mx; 23 cvector_t freelist; 24} cpool_t; 25 26void cpool_init(cpool_t *p, uint32_t start, uint32_t end); 27 28void cpool_release(cpool_t *p); 29 30uint32_t cpool_alloc(cpool_t *p); 31 32void cpool_free(cpool_t *p, uint32_t obj); 33 34bool cpool_check(cpool_t *p, uint32_t obj); 35 36#endif /* _CALLOCPOOL_H_ */ 37