From: Michael Tremer Date: Fri, 10 Jul 2026 10:23:29 +0000 (+0000) Subject: buffer: Return the amount of bytes written X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e5c22d99e9bfeb08569069af1670f735cf870be;p=telemetry.git buffer: Return the amount of bytes written Signed-off-by: Michael Tremer --- diff --git a/src/daemon/buffer.c b/src/daemon/buffer.c index c186ed9..218bde4 100644 --- a/src/daemon/buffer.c +++ b/src/daemon/buffer.c @@ -194,6 +194,10 @@ int td_buffer_write(td_buffer* self, const char* chunk, size_t length) { if (td_buffer_has_flag(self, TELEMETRY_BUFFER_LOCKED)) return -ENOTSUP; + // Don't write empty chunks + if (!length) + return length; + // Increase the size of the buffer data = realloc(self->data, self->length + length); if (!data) { @@ -211,8 +215,8 @@ int td_buffer_write(td_buffer* self, const char* chunk, size_t length) { // Increase the size of the buffer self->length += length; - // Done - return 0; + // Return the length + return length; ERROR: if (data)