From eb9a4b9034453ae3093d678a6f3898303dc5a5a0 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Mon, 12 Jun 2023 18:32:12 +0200 Subject: libio: remove ostream_append_sparse and fallback implementation Instead of a separate append-sparse function, simply accept NULL as an input for append. For both Unix and Win32, a fallback needs to be implemented. For XFRM, we can just memset the input buffer to zero, same for the libsquashfs data writer. Signed-off-by: David Oberhollenzer --- lib/io/src/xfrm/ostream.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/io/src/xfrm') diff --git a/lib/io/src/xfrm/ostream.c b/lib/io/src/xfrm/ostream.c index 79ed49a..e55e38c 100644 --- a/lib/io/src/xfrm/ostream.c +++ b/lib/io/src/xfrm/ostream.c @@ -82,10 +82,14 @@ static int xfrm_append(ostream_t *strm, const void *data, size_t size) if (diff > size) diff = size; - memcpy(xfrm->inbuf + xfrm->inbuf_used, data, diff); + if (data == NULL) { + memset(xfrm->inbuf + xfrm->inbuf_used, 0, diff); + } else { + memcpy(xfrm->inbuf + xfrm->inbuf_used, data, diff); + data = (const char *)data + diff; + } xfrm->inbuf_used += diff; - data = (const char *)data + diff; size -= diff; } -- cgit v1.2.3