Revision f8562e32

b/ui/vnc-palette.c
126 126
        }
127 127
    }
128 128
}
129

  
130
uint32_t palette_color(const VncPalette *palette, int idx, bool *found)
131
{
132
    int i;
133
    VncPaletteEntry *entry;
134

  
135
    for (i = 0; i < VNC_PALETTE_HASH_SIZE; i++) {
136
        QLIST_FOREACH(entry, &palette->table[i], next) {
137
            if (entry->idx == idx) {
138
                *found = true;
139
                return entry->color;
140
            }
141
        }
142
    }
143

  
144
    *found = false;
145
    return -1;
146
}
147

  
148
static void palette_fill_cb(int idx, uint32_t color, void *opaque)
149
{
150
    uint32_t *colors = opaque;
151

  
152
    colors[idx] = color;
153
}
154

  
155
size_t palette_fill(const VncPalette *palette,
156
                    uint32_t colors[VNC_PALETTE_MAX_SIZE])
157
{
158
    palette_iter(palette, palette_fill_cb, colors);
159
    return palette_size(palette);
160
}
b/ui/vnc-palette.h
61 61
void palette_iter(const VncPalette *palette,
62 62
                  void (*iter)(int idx, uint32_t color, void *opaque),
63 63
                  void *opaque);
64
uint32_t palette_color(const VncPalette *palette, int idx, bool *found);
65
size_t palette_fill(const VncPalette *palette,
66
                    uint32_t colors[VNC_PALETTE_MAX_SIZE]);
64 67

  
65 68
#endif /* VNC_PALETTE_H */

Also available in: Unified diff