/**/
void *
_band_get_aligned(
Band * const p,
const size_t alignment,
const size_t size )
{
Block * which;
ListNode * x;
if (!__mallocsizes_inited) {
__malloc_sizes_init();
}
assert(size <= p->nbpe);
if (alignment != _MALLOC_ALIGN) {
assert(band_align_ok(p, alignment));
assert((sizeof(void*) * (alignment/sizeof(void*))) == alignment
&& "alignment must be a multiple of sizeof(void*)");
}
if ((which = p->alist) != NULL) {
if (alignment != _MALLOC_ALIGN) {
x = (ListNode *)_block_memalign(p, which, alignment);
}
else {
x = (ListNode *)_block_mem_malloc_align(p, which);
}
if (x != NULL) {
#ifdef STATISTICS
p->alloc_counter++;
#endif
x->ln_offset = (char *)which - (char *)x;
assert(x->ln_offset < 0);
assert(which->navail > 0);
/*
* If no more blocks, put this on the depleted-list
*/
if (--which->navail == 0) {
Block *b;
assert(which->head == NULL);
assert(which->prev == NULL);
/*
* Simple delete -- which is first.
*/
p->alist = b = which->next;
if (b)
b->prev = NULL;
/*
* insert into d(epleted)list
*/
which->next = b = p->dlist;
p->dlist = which;
if (b)
b->prev = which;
}
_malloc_stats.m_small_allocmem += p->nbpe;
_malloc_stats.m_small_freemem -= p->nbpe;
return x+1;
}
}
if ((which = band_addblk(p)) == NULL) {
return 0; /* failed */
}
assert(which->navail);
return _band_get_aligned(p, alignment, size);
} /* _band_get_aligned */