From patchwork Thu Sep 3 10:29:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 513910 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1293A140280 for ; Thu, 3 Sep 2015 20:30:08 +1000 (AEST) Received: from localhost ([::1]:46630 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXRmP-0008Og-Tc for incoming@patchwork.ozlabs.org; Thu, 03 Sep 2015 06:30:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44322) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXRm4-0007uP-C4 for qemu-devel@nongnu.org; Thu, 03 Sep 2015 06:29:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZXRm1-0004TI-80 for qemu-devel@nongnu.org; Thu, 03 Sep 2015 06:29:44 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:57521 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZXRm0-0004Sw-Tb for qemu-devel@nongnu.org; Thu, 03 Sep 2015 06:29:41 -0400 Received: (qmail 10408 invoked by uid 89); 3 Sep 2015 10:29:39 -0000 Received: from [195.62.97.28] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.98.7/20872. hbedv: 8.3.34.10/7.12.6.54. spamassassin: 3.4.0. Clear:RC:1(195.62.97.28):SA:0(-2.0/5.0):. Processed in 2.260466 secs); 03 Sep 2015 10:29:39 -0000 Received: from smtp.kamp.de (HELO submission.kamp.de) ([195.62.97.28]) by mx01.kamp.de with ESMTPS (DHE-RSA-AES256-SHA encrypted); 3 Sep 2015 10:29:36 -0000 X-GL_Whitelist: yes Received: (qmail 31951 invoked from network); 3 Sep 2015 10:18:10 -0000 Received: from lieven-pc.kamp-intra.net (HELO ?172.21.12.60?) (pl@kamp.de@172.21.12.60) by submission.kamp.de with ESMTPS (DHE-RSA-AES128-SHA encrypted) ESMTPA; 3 Sep 2015 10:18:10 -0000 To: Gerd Hoffmann References: <1440670734-5616-1-git-send-email-pl@kamp.de> <1440670734-5616-2-git-send-email-pl@kamp.de> <1441270602.557.12.camel@redhat.com> From: Peter Lieven Message-ID: <55E82110.2070504@kamp.de> 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 MIME-Version: 1.0 In-Reply-To: <1441270602.557.12.camel@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:248:0:51::16 Cc: qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [PATCH 1/4] vnc: make the Buffer capacity increase in powers of two X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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: BR, Peter 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); }