buffer: Calculate the offsets in set_size only after resizing the buffer
Added clang-format cfg and reformated the code