ref: 9e0a5c0c9bfcb4fe6b4b91149ffff93f3a9e8766
dir: /src/bitvector.c/
#include "sl.h"
uint32_t *
bitvector_resize(uint32_t *b, uint64_t oldsz, uint64_t newsz, bool zero)
{
uint32_t *p;
size_t sz = ((newsz+31)>>5) * sizeof(uint32_t);
p = MEM_REALLOC(b, sz);
if(p == nil)
return nil;
if(zero && newsz > oldsz){
size_t osz = ((oldsz+31)>>5) * sizeof(uint32_t);
memset(&p[osz/sizeof(uint32_t)], 0, sz-osz);
}
return p;
}