Revision e31e3694
b/ui/vnc-palette.c | ||
---|---|---|
63 | 63 |
|
64 | 64 |
void palette_destroy(VncPalette *palette) |
65 | 65 |
{ |
66 |
int i; |
|
67 |
|
|
68 | 66 |
if (palette == NULL) { |
69 |
return ;
|
|
67 |
qemu_free(palette);
|
|
70 | 68 |
} |
71 |
|
|
72 |
for (i = 0; i < VNC_PALETTE_HASH_SIZE; i++) { |
|
73 |
VncPaletteEntry *entry = QLIST_FIRST(&palette->table[i]); |
|
74 |
while (entry) { |
|
75 |
VncPaletteEntry *tmp = QLIST_NEXT(entry, next); |
|
76 |
QLIST_REMOVE(entry, next); |
|
77 |
qemu_free(entry); |
|
78 |
entry = tmp; |
|
79 |
} |
|
80 |
} |
|
81 |
|
|
82 |
qemu_free(palette); |
|
83 | 69 |
} |
84 | 70 |
|
85 | 71 |
int palette_put(VncPalette *palette, uint32_t color) |
... | ... | |
97 | 83 |
if (!entry) { |
98 | 84 |
VncPaletteEntry *entry; |
99 | 85 |
|
100 |
entry = qemu_mallocz(sizeof(*entry));
|
|
86 |
entry = &palette->pool[palette->size];
|
|
101 | 87 |
entry->color = color; |
102 | 88 |
entry->idx = idx; |
103 | 89 |
QLIST_INSERT_HEAD(&palette->table[hash], entry, next); |
b/ui/vnc-palette.h | ||
---|---|---|
34 | 34 |
#include <stdint.h> |
35 | 35 |
|
36 | 36 |
#define VNC_PALETTE_HASH_SIZE 256 |
37 |
#define VNC_PALETTE_MAX_SIZE 256 |
|
37 | 38 |
|
38 | 39 |
typedef struct VncPaletteEntry { |
39 | 40 |
int idx; |
... | ... | |
42 | 43 |
} VncPaletteEntry; |
43 | 44 |
|
44 | 45 |
typedef struct VncPalette { |
45 |
QObject_HEAD;
|
|
46 |
VncPaletteEntry pool[VNC_PALETTE_MAX_SIZE];
|
|
46 | 47 |
size_t size; |
47 | 48 |
size_t max; |
48 | 49 |
int bpp; |
Also available in: Unified diff