MCPcopy Create free account
hub / github.com/OSGeo/PROJ / pj_insert_initcache

Function pj_insert_initcache

src/initcache.cpp:134–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132/************************************************************************/
133
134void pj_insert_initcache(const char *filekey, const paralist *list)
135
136{
137 pj_acquire_lock();
138
139 /*
140 ** Grow list if required.
141 */
142 if (cache_count == cache_alloc) {
143 char **cache_key_new;
144 paralist **cache_paralist_new;
145
146 cache_alloc = cache_alloc * 2 + 15;
147
148 cache_key_new = (char **)malloc(sizeof(char *) * cache_alloc);
149 assert(cache_key_new);
150 if (cache_key && cache_count) {
151 memcpy(cache_key_new, cache_key, sizeof(char *) * cache_count);
152 }
153 free(cache_key);
154 cache_key = cache_key_new;
155
156 cache_paralist_new =
157 (paralist **)malloc(sizeof(paralist *) * cache_alloc);
158 assert(cache_paralist_new);
159 if (cache_paralist && cache_count) {
160 memcpy(cache_paralist_new, cache_paralist,
161 sizeof(paralist *) * cache_count);
162 }
163 free(cache_paralist);
164 cache_paralist = cache_paralist_new;
165 }
166
167 /*
168 ** Duplicate the filekey and paralist, and insert in cache.
169 */
170 cache_key[cache_count] = (char *)malloc(strlen(filekey) + 1);
171 assert(cache_key[cache_count]);
172 strcpy(cache_key[cache_count], filekey);
173
174 cache_paralist[cache_count] = pj_clone_paralist(list);
175
176 cache_count++;
177
178 pj_release_lock();
179}

Callers 1

get_initFunction · 0.85

Calls 3

pj_acquire_lockFunction · 0.85
pj_clone_paralistFunction · 0.85
pj_release_lockFunction · 0.85

Tested by

no test coverage detected