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