This potentially can also save the copy if there are enough space to resize the buffer in place. Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx> --- server/mjpeg-encoder.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/server/mjpeg-encoder.c b/server/mjpeg-encoder.c index 15f5e1f2f..07ca69c20 100644 --- a/server/mjpeg-encoder.c +++ b/server/mjpeg-encoder.c @@ -278,15 +278,11 @@ static boolean empty_mem_output_buffer(j_compress_ptr cinfo) /* Try to allocate new buffer with double size */ nextsize = dest->bufsize * 2; - nextbuffer = malloc(nextsize); + nextbuffer = realloc(dest->buffer, nextsize); if (nextbuffer == NULL) ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10); - memcpy(nextbuffer, dest->buffer, dest->bufsize); - - free(dest->buffer); - dest->pub.next_output_byte = nextbuffer + dest->bufsize; dest->pub.free_in_buffer = dest->bufsize; -- 2.13.5 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel