Lines Matching refs:alloc
82 bool bmallocator_init(struct bmallocator *alloc, size_t n)
84 alloc->count = n;
85 alloc->bitmap = calloc((n + BMALLOCATOR_BITS - 1) / BMALLOCATOR_BITS,
87 return alloc->bitmap != NULL;
91 void bmallocator_destroy(struct bmallocator *alloc)
93 free(alloc->bitmap);
94 alloc->bitmap = NULL;
98 bool bmallocator_alloc(struct bmallocator *alloc, size_t *n)
105 for (i = 0; i < alloc->count; i++) {
109 if (!(alloc->bitmap[idx] & bit)) {
110 alloc->bitmap[idx] |= bit;
119 bool bmallocator_free(struct bmallocator *alloc, size_t n)
125 if (n >= alloc->count) {
132 result = alloc->bitmap[idx] & bit;
133 alloc->bitmap[idx] &= ~bit;