qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/4] vnc: make the Buffer capacity increase in p


From: Peter Lieven
Subject: Re: [Qemu-devel] [PATCH 1/4] vnc: make the Buffer capacity increase in powers of two
Date: Thu, 3 Sep 2015 12:29:36 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0

Am 03.09.2015 um 10:56 schrieb Gerd Hoffmann:
On Do, 2015-08-27 at 12:18 +0200, Peter Lieven wrote:
This makes sure the number of reallocs is in O(log N).
Looks good, applied.


I think there is a small error. The new capacity should be calculated as 
follows:

diff --git a/ui/vnc.c b/ui/vnc.c
index 8cfd2d8..79d3ff3 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -658,7 +658,7 @@ void vnc_framebuffer_update(VncState *vs, int x, int y, int 
w, int h,
 void buffer_reserve(Buffer *buffer, size_t len)
 {
     if ((buffer->capacity - buffer->offset) < len) {
-        buffer->capacity = pow2ceil(buffer->capacity + len);
+        buffer->capacity = pow2ceil(buffer->offset + len);
         buffer->capacity = MAX(buffer->capacity, BUFFER_MIN_INIT_SIZE);
         buffer->buffer = g_realloc(buffer->buffer, buffer->capacity);
     }


BR,
Peter



reply via email to

[Prev in Thread] Current Thread [Next in Thread]