aboutsummaryrefslogtreecommitdiff
path: root/ui/vnc-palette.c
diff options
context:
space:
mode:
authorCorentin Chary <corentincj@iksaif.net>2011-02-04 09:05:58 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2011-02-23 16:28:28 -0600
commite31e3694afef58ba191cbcc6875ec243e5971268 (patch)
treeb5a18832ceb272a347843d9ed7b7798dd67b0079 /ui/vnc-palette.c
parentce702e93b0b99562ed42ba5c078914f2209b9a6a (diff)
downloadqemu-e31e3694afef58ba191cbcc6875ec243e5971268.zip
qemu-e31e3694afef58ba191cbcc6875ec243e5971268.tar.gz
qemu-e31e3694afef58ba191cbcc6875ec243e5971268.tar.bz2
vnc: palette: use a pool to reduce memory allocations
We now that the palette will never have more than 256 elements. Let's use a pool to reduce malloc calls. Signed-off-by: Corentin Chary <corentincj@iksaif.net> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'ui/vnc-palette.c')
-rw-r--r--ui/vnc-palette.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/ui/vnc-palette.c b/ui/vnc-palette.c
index bff6445..c47420b 100644
--- a/ui/vnc-palette.c
+++ b/ui/vnc-palette.c
@@ -63,23 +63,9 @@ VncPalette *palette_new(size_t max, int bpp)
void palette_destroy(VncPalette *palette)
{
- int i;
-
if (palette == NULL) {
- return ;
+ qemu_free(palette);
}
-
- for (i = 0; i < VNC_PALETTE_HASH_SIZE; i++) {
- VncPaletteEntry *entry = QLIST_FIRST(&palette->table[i]);
- while (entry) {
- VncPaletteEntry *tmp = QLIST_NEXT(entry, next);
- QLIST_REMOVE(entry, next);
- qemu_free(entry);
- entry = tmp;
- }
- }
-
- qemu_free(palette);
}
int palette_put(VncPalette *palette, uint32_t color)
@@ -97,7 +83,7 @@ int palette_put(VncPalette *palette, uint32_t color)
if (!entry) {
VncPaletteEntry *entry;
- entry = qemu_mallocz(sizeof(*entry));
+ entry = &palette->pool[palette->size];
entry->color = color;
entry->idx = idx;
QLIST_INSERT_HEAD(&palette->table[hash], entry, next);