tb.h: refactor bitmap setting, add reallocation function