shithub: sl

ref: 12c9d2fc728b51aa1eb9a70d0d331eb9464912d9
dir: /src/bitvector.c/

View raw version
#include "sl.h"

u32int *
bitvector_resize(u32int *b, u64int oldsz, u64int newsz, bool zero)
{
	u32int *p;
	usize sz = ((newsz+31)>>5) * sizeof(u32int);
	p = MEM_REALLOC(b, sz);
	if(p == nil)
		return nil;
	if(zero && newsz > oldsz){
		usize osz = ((oldsz+31)>>5) * sizeof(u32int);
		memset(&p[osz/sizeof(u32int)], 0, sz-osz);
	}
	return p;
}