Patchwork [06/15] vnc: palette: add palette_init calls

login
register
mail settings
Submitter Corentin Chary
Date Aug. 11, 2010, 5:49 a.m.
Message ID <1281505785-22523-7-git-send-email-corentincj@iksaif.net>
Download mbox | patch
Permalink /patch/61445/
State New
Headers show

Comments

Corentin Chary - Aug. 11, 2010, 5:49 a.m.
This allow to use palette on the stack instead of always
allocating them.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
 ui/vnc-palette.c |    8 +++++++-
 ui/vnc-palette.h |    1 +
 2 files changed, 8 insertions(+), 1 deletions(-)

Patch

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);