2 * FreeRDP: A Remote Desktop Protocol Client
5 * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 #include <freerdp/utils/stream.h>
21 #include <freerdp/utils/memory.h>
23 #include <freerdp/cache/color_table.h>
25 void* color_table_get(rdpColorTableCache* color_table, uint8 index)
29 if (index > color_table->maxEntries)
31 printf("invalid color table index: 0x%04X\n", index);
35 entry = color_table->entries[index].entry;
39 printf("invalid color table at index: 0x%04X\n", index);
46 void color_table_put(rdpColorTableCache* color_table, uint8 index, void* entry)
48 if (index > color_table->maxEntries)
50 printf("invalid color table index: 0x%04X\n", index);
54 color_table->entries[index].entry = entry;
57 rdpColorTableCache* color_table_cache_new(rdpSettings* settings)
59 rdpColorTableCache* color_table;
61 color_table = (rdpColorTableCache*) xzalloc(sizeof(rdpColorTableCache));
63 if (color_table != NULL)
65 color_table->settings = settings;
67 color_table->maxEntries = 6;
69 color_table->entries = (COLOR_TABLE_ENTRY*) xzalloc(sizeof(COLOR_TABLE_ENTRY) * color_table->maxEntries);
75 void color_table_cache_free(rdpColorTableCache* color_table)
77 if (color_table != NULL)
79 xfree(color_table->entries);