use size_t; fixed misplaced offset increase

Got a compile warning due to `offset` being an `int` but comparing to results of `sizeof`. Also fixed a misplaced `offset` increase.