summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2022-11-26 11:15:59 -0500
committerRay Strode <rstrode@redhat.com>2022-11-29 09:22:06 -0500
commitab0559893eb1a53896b2de54743464dda9682c69 (patch)
tree8d9e45313fff334e49536c3b3f8cec7f499d1e78
parent288d0aca0289911d1bf691d03775334b18d019e7 (diff)
buffer: Support length == 0 for ply_buffer_append_bytes
Right now callers of ply_buffer_append_bytes have to be very careful to make sure the data they're appending is non-zero in length. This is kind of inconvenient, since it's not unusual for data to come in that's zero bytes long. For simplicity, this commit just makes ply_buffer_append_bytes support that use case.
-rw-r--r--src/libply/ply-buffer.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/libply/ply-buffer.c b/src/libply/ply-buffer.c
index 7392ee6b..e91eb0d6 100644
--- a/src/libply/ply-buffer.c
+++ b/src/libply/ply-buffer.c
@@ -181,10 +181,12 @@ ply_buffer_append_bytes (ply_buffer_t *buffer,
{
assert (buffer != NULL);
assert (bytes_in != NULL);
- assert (length != 0);
const uint8_t *bytes = bytes_in;
+ if (length == 0)
+ return;
+
if (length > PLY_BUFFER_MAX_BUFFER_CAPACITY) {
bytes += length - (PLY_BUFFER_MAX_BUFFER_CAPACITY - 1);
length = (PLY_BUFFER_MAX_BUFFER_CAPACITY - 1);
@@ -257,4 +259,3 @@ ply_buffer_clear (ply_buffer_t *buffer)
memset (buffer->data, '\0', buffer->capacity);
buffer->size = 0;
}
-