From patchwork Fri Feb 4 08:05:59 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Chary X-Patchwork-Id: 81824 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by ozlabs.org (Postfix) with ESMTP id 8182AB70FF for ; Fri, 4 Feb 2011 19:32:23 +1100 (EST) Received: from localhost ([127.0.0.1]:56648 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PlH0d-00031S-O3 for incoming@patchwork.ozlabs.org; Fri, 04 Feb 2011 03:27:15 -0500 Received: from [140.186.70.92] (port=49404 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PlGfB-0003in-2Z for qemu-devel@nongnu.org; Fri, 04 Feb 2011 03:05:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PlGf9-0001l7-Ni for qemu-devel@nongnu.org; Fri, 04 Feb 2011 03:05:05 -0500 Received: from smtp5-g21.free.fr ([212.27.42.5]:51796) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PlGf9-0001kg-5k for qemu-devel@nongnu.org; Fri, 04 Feb 2011 03:05:03 -0500 Received: from localhost.localdomain (unknown [82.241.209.44]) by smtp5-g21.free.fr (Postfix) with ESMTP id D8172D482DE; Fri, 4 Feb 2011 09:04:57 +0100 (CET) From: Corentin Chary To: Anthony Liguori Date: Fri, 4 Feb 2011 09:05:59 +0100 Message-Id: <1296806768-27787-8-git-send-email-corentincj@iksaif.net> X-Mailer: git-send-email 1.7.4 In-Reply-To: <1296806768-27787-1-git-send-email-corentincj@iksaif.net> References: <1296806768-27787-1-git-send-email-corentincj@iksaif.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 212.27.42.5 Cc: Corentin Chary , Andre Przywara , Qemu-development List , Alexander Graf Subject: [Qemu-devel] [PATCH v3 07/16] vnc: palette: add palette_init calls X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This allow to use palette on the stack instead of always allocating them. Signed-off-by: Corentin Chary --- ui/vnc-palette.c | 8 +++++++- ui/vnc-palette.h | 1 + 2 files changed, 8 insertions(+), 1 deletions(-) diff --git a/ui/vnc-palette.c b/ui/vnc-palette.c index c47420b..f93250b 100644 --- a/ui/vnc-palette.c +++ b/ui/vnc-palette.c @@ -56,9 +56,15 @@ VncPalette *palette_new(size_t max, int bpp) VncPalette *palette; palette = qemu_mallocz(sizeof(*palette)); + palette_init(palette, max, bpp); + return palette; +} + +void palette_init(VncPalette *palette, size_t max, int bpp) +{ + memset(palette, 0, sizeof (*palette)); palette->max = max; palette->bpp = bpp; - return palette; } void palette_destroy(VncPalette *palette) diff --git a/ui/vnc-palette.h b/ui/vnc-palette.h index f57d0e7..c646e4d 100644 --- a/ui/vnc-palette.h +++ b/ui/vnc-palette.h @@ -51,6 +51,7 @@ typedef struct VncPalette { } VncPalette; VncPalette *palette_new(size_t max, int bpp); +void palette_init(VncPalette *palette, size_t max, int bpp); void palette_destroy(VncPalette *palette); int palette_put(VncPalette *palette, uint32_t color);