Explorar el Código

vnc: palette: add palette_init calls

This allow to use palette on the stack instead of always
allocating them.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Corentin Chary hace 14 años
padre
commit
72aefb76f9
Se han modificado 2 ficheros con 8 adiciones y 1 borrados
  1. 7 1
      ui/vnc-palette.c
  2. 1 0
      ui/vnc-palette.h

+ 7 - 1
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)

+ 1 - 0
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);