From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=52062 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PGaSW-0008V5-El for qemu-devel@nongnu.org; Thu, 11 Nov 2010 11:57:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PGaSU-0005Yg-9T for qemu-devel@nongnu.org; Thu, 11 Nov 2010 11:57:12 -0500 Received: from relay2-v.mail.gandi.net ([217.70.178.76]:38424) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PGaSU-0005YL-4l for qemu-devel@nongnu.org; Thu, 11 Nov 2010 11:57:10 -0500 From: Corentin Chary Date: Thu, 11 Nov 2010 17:56:55 +0100 Message-Id: <1289494624-12807-7-git-send-email-corentincj@iksaif.net> In-Reply-To: <1289494624-12807-1-git-send-email-corentincj@iksaif.net> References: <1289494624-12807-1-git-send-email-corentincj@iksaif.net> Subject: [Qemu-devel] [PATCH v2 06/15] vnc: palette: add palette_init calls List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Qemu-development List Cc: Corentin Chary , Anthony Liguori , Alexander Graf , Andre Przywara 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); -- 1.7.3.2