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>
22 #include <freerdp/utils/hexdump.h>
23 #include <freerdp/utils/unicode.h>
25 #include <freerdp/rail/icon.h>
27 ICON_INFO* icon_cache_get(rdpIconCache* cache, uint8 id, uint16 index, void** extra)
31 if (id >= cache->numCaches)
33 printf("invalid window icon cache id:%d\n", id);
34 return (ICON_INFO*) NULL;
37 if (index >= cache->numCacheEntries)
39 printf("invalid window icon cache index:%d in cache id:%d\n", index, id);
40 return (ICON_INFO*) NULL;
43 entry = cache->caches[id].entries[index].entry;
46 *extra = cache->caches[id].entries[index].extra;
51 void icon_cache_put(rdpIconCache* cache, uint8 id, uint16 index, ICON_INFO* entry, void* extra)
53 if (id >= cache->numCaches)
55 printf("invalid window icon cache id:%d\n", id);
59 if (index >= cache->numCacheEntries)
61 printf("invalid window icon cache index:%d in cache id:%d\n", index, id);
65 cache->caches[id].entries[index].entry = entry;
68 cache->caches[id].entries[index].extra = extra;
71 rdpIconCache* icon_cache_new(rdpRail* rail)
75 cache = (rdpIconCache*) xzalloc(sizeof(rdpIconCache));
82 cache->numCaches = (uint8) rail->settings->num_icon_cache_entries;
83 cache->numCacheEntries = rail->settings->num_icon_cache_entries;
85 cache->caches = xzalloc(cache->numCaches * sizeof(WINDOW_ICON_CACHE));
87 for (i = 0; i < cache->numCaches; i++)
89 cache->caches[i].entries = xzalloc(cache->numCacheEntries * sizeof(rdpIconCache));
96 void icon_cache_free(rdpIconCache* cache)
102 for (i = 0; i < cache->numCaches; i++)
104 xfree(cache->caches[i].entries);
107 xfree(cache->caches);