>buff = realloc(buff, allocsz)

リークするからやめなよ。