Writes zeros to output buffer to align the next write to the requested alignment. "size" is the current size of the buffer and is updated to the new size.
| 384 | // alignment. "size" is the current size of the buffer and is updated to the |
| 385 | // new size. |
| 386 | Status PadAlignment(FileOutputBuffer* out, int alignment, int64* size) { |
| 387 | int bytes_over = *size % alignment; |
| 388 | if (bytes_over == 0) { |
| 389 | return Status::OK(); |
| 390 | } |
| 391 | int bytes_to_write = alignment - bytes_over; |
| 392 | Status status = out->Append(string(bytes_to_write, '\0')); |
| 393 | if (status.ok()) { |
| 394 | *size += bytes_to_write; |
| 395 | } |
| 396 | return status; |
| 397 | } |
| 398 | |
| 399 | } // namespace |
| 400 |