GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
cache1.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <sys/types.h>
5 #include <unistd.h>
6 #include <grass/raster3d.h>
7 #include "raster3d_intern.h"
8 #include "cachehash.h"
9 
10 /*---------------------------------------------------------------------------*/
11 
12 #define IS_ACTIVE_ELT(elt) (c->locks[elt] != 2)
13 #define IS_NOT_ACTIVE_ELT(elt) (c->locks[elt] == 2)
14 #define IS_LOCKED_ELT(elt) (c->locks[elt] == 1)
15 #define IS_UNLOCKED_ELT(elt) (c->locks[elt] == 0)
16 #define IS_NOT_IN_QUEUE_ELT(elt) (IS_LOCKED_ELT (elt))
17 #define IS_IN_QUEUE_ELT(elt) (! IS_NOT_IN_QUEUE_ELT (elt))
18 
19 #define DEACTIVATE_ELT(elt) ((IS_LOCKED_ELT(elt) ? \
20  (c->nofUnlocked)++ : (0)), \
21  c->locks[elt] = 2)
22 #define LOCK_ELT(elt) ((IS_LOCKED_ELT(elt) ? \
23  (0) : (c->nofUnlocked)--), \
24  (c->locks[elt] = 1))
25 #define UNLOCK_ELT(elt) ((IS_LOCKED_ELT(elt) ? \
26  (c->nofUnlocked)++ : (0)), \
27  (c->locks[elt] = 0))
28 
29 #define ONE_UNLOCKED_ELT_ONLY (c->first == c->last)
30 #define ARE_MIN_UNLOCKED (c->nofUnlocked <= c->minUnlocked)
31 
32 /*---------------------------------------------------------------------------*/
33 
35 {
36  int i;
37 
38  for (i = 0; i < c->nofElts; i++) {
39  DEACTIVATE_ELT(i);
40  c->next[i] = i + 1;
41  c->prev[i] = i - 1;
42  c->names[i] = -1;
43  }
44 
45  c->prev[0] = c->next[c->nofElts - 1] = -1;
46  c->first = 0;
47  c->last = c->nofElts - 1;
48 
49  c->autoLock = 0;
50  c->nofUnlocked = c->nofElts;
51  c->minUnlocked = 1;
52 
54 }
55 
56 /*---------------------------------------------------------------------------*/
57 
58 static int cache_dummy_fun(int tileIndex, const void *tileBuf, void *map)
59 {
60  return 1;
61 }
62 
63 /*---------------------------------------------------------------------------*/
64 
66 {
67  if (c == NULL)
68  return;
69 
71 
72  if (c->elts != NULL)
73  Rast3d_free(c->elts);
74  if (c->names != NULL)
75  Rast3d_free(c->names);
76  if (c->locks != NULL)
77  Rast3d_free(c->locks);
78  if (c->next != NULL)
79  Rast3d_free(c->next);
80  if (c->prev != NULL)
81  Rast3d_free(c->prev);
82 
83  Rast3d_free(c);
84 }
85 
86 /*---------------------------------------------------------------------------*/
87 
88 void *Rast3d_cache_new(int nofElts, int sizeOfElts, int nofNames,
89  int (*eltRemoveFun) (), void *eltRemoveFunData,
90  int (*eltLoadFun) (), void *eltLoadFunData)
91 {
92  RASTER3D_cache *tmp;
93  int i;
94 
95  tmp = Rast3d_malloc(sizeof(RASTER3D_cache));
96  if (tmp == NULL) {
97  Rast3d_error("Rast3d_cache_new: error in Rast3d_malloc");
98  return (void *)NULL;
99  }
100 
101  tmp->hash = NULL;
102 
103  tmp->nofElts = nofElts;
104  tmp->eltSize = sizeOfElts;
105  tmp->elts = Rast3d_malloc(tmp->eltSize * tmp->nofElts);
106  tmp->names = Rast3d_malloc(sizeof(int) * tmp->nofElts);
107  tmp->locks = Rast3d_malloc(tmp->nofElts);
108  tmp->next = Rast3d_malloc(sizeof(int) * tmp->nofElts);
109  tmp->prev = Rast3d_malloc(sizeof(int) * tmp->nofElts);
110 
111  if ((tmp->elts == NULL) || (tmp->names == NULL) || (tmp->locks == NULL) ||
112  (tmp->next == NULL) || (tmp->prev == NULL)) {
113 
115  Rast3d_error("Rast3d_cache_new: error in Rast3d_malloc");
116  return (void *)NULL;
117  }
118  /* Init the cache lock */
119  for(i = 0; i < tmp->nofElts; i++)
120  tmp->locks[i] = 0;
121 
122  tmp->eltRemoveFun = eltRemoveFun;
123  tmp->eltRemoveFunData = eltRemoveFunData;
124  tmp->eltLoadFun = eltLoadFun;
125  tmp->eltLoadFunData = eltLoadFunData;
126 
127  tmp->hash = Rast3d_cache_hash_new(nofNames);
128  if (tmp->hash == NULL) {
130  Rast3d_error("Rast3d_cache_new: error in Rast3d_cache_hash_new");
131  return (void *)NULL;
132  }
133 
134  Rast3d_cache_reset(tmp);
135 
136  return tmp;
137 }
138 
139 /*---------------------------------------------------------------------------*/
140 
141 void
142 Rast3d_cache_set_remove_fun(RASTER3D_cache * c, int (*eltRemoveFun) (),
143  void *eltRemoveFunData)
144 {
145  c->eltRemoveFun = eltRemoveFun;
146  c->eltRemoveFunData = eltRemoveFunData;
147 }
148 
149 /*---------------------------------------------------------------------------*/
150 
151 void
152 Rast3d_cache_set_load_fun(RASTER3D_cache * c, int (*eltLoadFun) (),
153  void *eltLoadFunData)
154 {
155  c->eltLoadFun = eltLoadFun;
156  c->eltLoadFunData = eltLoadFunData;
157 }
158 
159 /*---------------------------------------------------------------------------*/
160 
161 void *Rast3d_cache_new_read(int nofElts, int sizeOfElts, int nofNames,
162  read_fn * eltLoadFun, void *eltLoadFunData)
163 {
164  return Rast3d_cache_new(nofElts, sizeOfElts, nofNames,
165  cache_dummy_fun, NULL, eltLoadFun, eltLoadFunData);
166 }
167 
168 /*---------------------------------------------------------------------------*/
169 
170 static void cache_queue_dequeue(RASTER3D_cache * c, int index)
171 {
172  if (IS_NOT_IN_QUEUE_ELT(index))
173  Rast3d_fatal_error("cache_queue_dequeue: index not in queue");
174 
175  if (index == c->first)
176  c->first = c->next[index];
177  if (index == c->last)
178  c->last = c->prev[index];
179 
180  if (c->next[index] != -1)
181  c->prev[c->next[index]] = c->prev[index];
182  if (c->prev[index] != -1)
183  c->next[c->prev[index]] = c->next[index];
184 
185  c->next[index] = c->prev[index] = -1;
186 }
187 
188 /*---------------------------------------------------------------------------*/
189 
190 static void cache_queue_enqueue(RASTER3D_cache * c, int left, int index)
191 {
192  if (IS_IN_QUEUE_ELT(index))
193  Rast3d_fatal_error("cache_queue_enqueue: index already in queue");
194 
195  if (c->first == -1) {
196  if (left != c->last)
197  Rast3d_fatal_error("cache_queue_enqueue: position out of range");
198 
199  c->first = c->last = index;
200  return;
201  }
202 
203  if (left >= 0 && IS_NOT_IN_QUEUE_ELT(left))
204  Rast3d_fatal_error("cache_queue_enqueue: position not in queue");
205 
206 
207  if (left == -1) {
208  c->next[index] = c->first;
209  c->prev[c->first] = index;
210  c->first = index;
211 
212  return;
213  }
214 
215  c->prev[index] = left;
216 
217  if (c->next[left] == -1) {
218  c->next[left] = index;
219  c->last = index;
220 
221  return;
222  }
223 
224  c->prev[c->next[left]] = index;
225  c->next[index] = c->next[left];
226  c->next[left] = index;
227 }
228 
229 /*---------------------------------------------------------------------------*/
230 
231 static int cache_queue_get_top(RASTER3D_cache * c)
232 {
233  int top;
234 
235  top = c->first;
236 
237  cache_queue_dequeue(c, c->first);
238 
239  return top;
240 }
241 
242 /*---------------------------------------------------------------------------*/
243 
244 static void cache_queue_append(RASTER3D_cache * c, int index)
245 {
246  cache_queue_enqueue(c, c->last, index);
247 }
248 
249 /*---------------------------------------------------------------------------*/
250 
251 static void cache_queue_preppend(RASTER3D_cache * c, int index)
252 {
253  cache_queue_enqueue(c, -1, index);
254 }
255 
256 /*---------------------------------------------------------------------------*/
257 
258 /*---------------------------------------------------------------------------*/
259 
260  /* EXPORTED FUNCTIONS */
261 
262 /*---------------------------------------------------------------------------*/
263 
264 /*---------------------------------------------------------------------------*/
265 
267 {
268  int index;
269 
270  index = Rast3d_cache_hash_name2index(c->hash, name);
271  if (index == -1) {
272  Rast3d_error("Rast3d_cache_lock: name not in cache");
273  return 0;
274  }
275 
276  if (IS_LOCKED_ELT(index))
277  return 1;
279  return -1;
280  if (ARE_MIN_UNLOCKED)
281  return -1;
282 
283  cache_queue_dequeue(c, index);
284  LOCK_ELT(index);
285 
286  return 1;
287 }
288 
289 /*---------------------------------------------------------------------------*/
290 
292 {
293  if (IS_LOCKED_ELT(index))
294  return;
295 
296  cache_queue_dequeue(c, index);
297  LOCK_ELT(index);
298 }
299 
300 /*---------------------------------------------------------------------------*/
301 
303 {
304  int index;
305 
306  index = Rast3d_cache_hash_name2index(c->hash, name);
307  if (index == -1) {
308  Rast3d_error("Rast3d_cache_unlock: name not in cache");
309  return 0;
310  }
311 
312  if (IS_UNLOCKED_ELT(index))
313  return 1;
314 
315  cache_queue_append(c, index);
316  UNLOCK_ELT(index);
317 
318  return 1;
319 }
320 
321 /*---------------------------------------------------------------------------*/
322 
324 {
325  int index;
326 
327  for (index = 0; index < c->nofElts; index++)
328  if (IS_LOCKED_ELT(index))
329  if (!Rast3d_cache_unlock(c, c->names[index])) {
330  Rast3d_error("Rast3d_cache_unlock_all: error in Rast3d_cache_unlock");
331  return 0;
332  }
333 
334  return 1;
335 }
336 
337 /*---------------------------------------------------------------------------*/
338 
340 {
341  int index;
342 
343  for (index = 0; index < c->nofElts; index++)
344  if (IS_UNLOCKED_ELT(index))
345  Rast3d_cache_lock_intern(c, index);
346 
347  return 1;
348 }
349 
350 /*---------------------------------------------------------------------------*/
351 
353 {
354  c->autoLock = 1;
355 }
356 
357 /*---------------------------------------------------------------------------*/
358 
360 {
361  c->autoLock = 0;
362 }
363 
364 /*---------------------------------------------------------------------------*/
365 
366 void Rast3d_cache_set_min_unlock(RASTER3D_cache * c, int nofMinUnLocked)
367 {
368  c->minUnlocked = nofMinUnLocked;
369 }
370 
371 /*---------------------------------------------------------------------------*/
372 
373 static int cache_remove_elt(RASTER3D_cache * c, int name, int doFlush)
374 {
375  int index;
376 
377  index = Rast3d_cache_hash_name2index(c->hash, name);
378  if (index == -1) {
379  Rast3d_error("Rast3d_cache_deactivate_elt : name not in cache");
380  return 0;
381  }
382 
383  if (IS_NOT_ACTIVE_ELT(index))
384  return 1;
385 
386  if (IS_IN_QUEUE_ELT(index)) {
387  cache_queue_dequeue(c, index);
388  LOCK_ELT(index);
389  }
390 
391  if (doFlush)
392  if (!c->eltRemoveFun(name, c->elts + c->eltSize * index,
393  c->eltRemoveFunData)) {
394  Rast3d_error("cache_remove_elt: error in c->eltRemoveFun");
395  return 0;
396  }
397 
398  cache_queue_preppend(c, index);
399  DEACTIVATE_ELT(index);
400 
402 
403  return 1;
404 }
405 
406 /*---------------------------------------------------------------------------*/
407 
409 {
410  if (!cache_remove_elt(c, name, 0)) {
411  Rast3d_error("Rast3d_cache_remove_elt: error in cache_remove_elt");
412  return 0;
413  }
414 
415  return 1;
416 }
417 
418 /*---------------------------------------------------------------------------*/
419 
421 {
422  if (!cache_remove_elt(c, name, 1)) {
423  Rast3d_error("Rast3d_cache_flush: error in cache_remove_elt");
424  return 0;
425  }
426 
427  return 1;
428 }
429 
430 /*---------------------------------------------------------------------------*/
431 
433 {
434  int index;
435 
436  for (index = 0; index < c->nofElts; index++)
437  if (IS_ACTIVE_ELT(index))
438  if (!Rast3d_cache_remove_elt(c, c->names[index])) {
440  ("Rast3d_cache_remove_all: error in Rast3d_cache_remove_elt");
441  return 0;
442  }
443 
444  return 1;
445 }
446 
447 /*---------------------------------------------------------------------------*/
448 
450 {
451  int index;
452 
453  for (index = 0; index < c->nofElts; index++)
454  if (IS_ACTIVE_ELT(index))
455  if (!Rast3d_cache_flush(c, c->names[index])) {
456  Rast3d_error("Rast3d_cache_flush_all: error in Rast3d_cache_flush");
457  return 0;
458  }
459 
460  return 1;
461 }
462 
463 /*---------------------------------------------------------------------------*/
464 
466 {
467  int index, oldName, doUnlock;
468 
469  index = Rast3d_cache_hash_name2index(c->hash, name);
470 
471  if (index != -1) {
472  if (c->autoLock)
473  if (IS_UNLOCKED_ELT(index) && (!ONE_UNLOCKED_ELT_ONLY) &&
474  (!ARE_MIN_UNLOCKED))
475  Rast3d_cache_lock_intern(c, index);
476 
477  return c->elts + c->eltSize * index;
478  }
479 
480  index = c->first;
481  if (IS_ACTIVE_ELT(index)) {
482  oldName = c->names[index];
483  Rast3d_cache_hash_remove_name(c->hash, oldName);
484  if (!c->eltRemoveFun(oldName, c->elts + c->eltSize * index,
485  c->eltRemoveFunData)) {
486  Rast3d_error("Rast3d_cache_elt_ptr: error in c->eltRemoveFun");
487  return NULL;
488  }
489  }
490 
491  Rast3d_cache_hash_load_name(c->hash, name, index);
492 
493  doUnlock = ((!c->autoLock) || ONE_UNLOCKED_ELT_ONLY || ARE_MIN_UNLOCKED);
494 
495  UNLOCK_ELT(index);
496  c->names[index] = name;
497  Rast3d_cache_lock_intern(c, index);
498 
499  if (doUnlock)
500  if (!Rast3d_cache_unlock(c, name)) {
501  Rast3d_error("Rast3d_cache_elt_ptr: error in Rast3d_cache_unlock");
502  return NULL;
503  }
504 
505  if (!c->eltLoadFun(name, c->elts + c->eltSize * index, c->eltLoadFunData)) {
506  Rast3d_error("Rast3d_cache_elt_ptr: error in c->eltLoadFun");
507  return NULL;
508  }
509 
510  return c->elts + c->eltSize * index;
511 }
512 
513 /*---------------------------------------------------------------------------*/
514 
516 {
517  if (Rast3d_cache_elt_ptr(c, name) == NULL) {
518  Rast3d_error("Rast3d_cache_load: error in Rast3d_cache_elt_ptr");
519  return 0;
520  }
521 
522  return 1;
523 }
524 
525 /*---------------------------------------------------------------------------*/
526 
527 int Rast3d_cache_get_elt(RASTER3D_cache * c, int name, void *dst)
528 {
529  const void *elt;
530 
531  elt = Rast3d_cache_elt_ptr(c, name);
532  if (elt == NULL) {
533  Rast3d_error("Rast3d_cache_get_elt: error in Rast3d_cache_elt_ptr");
534  return 0;
535  }
536 
537  memcpy(dst, elt, c->eltSize);
538 
539  return 1;
540 }
541 
542 /*---------------------------------------------------------------------------*/
543 
544 int Rast3d_cache_put_elt(RASTER3D_cache * c, int name, const void *src)
545 {
546  void *elt;
547 
548  elt = Rast3d_cache_elt_ptr(c, name);
549  if (elt == NULL) {
550  Rast3d_error("Rast3d_cache_put_elt: error in Rast3d_cache_elt_ptr");
551  return 0;
552  }
553 
554  memcpy(elt, src, c->eltSize);
555 
556  return 1;
557 }
558 
559 /*---------------------------------------------------------------------------*/
560 
561 /*---------------------------------------------------------------------------*/
562 
563  /* TEST FUNCTIONS */
564 
565 /*---------------------------------------------------------------------------*/
566 
567 /*---------------------------------------------------------------------------*/
568 
569 static void cache_test_print(RASTER3D_cache * c)
570 {
571  int i, al;
572  int *a;
573 
574  al = c->autoLock;
576 
577  printf("\n--------------------------------\n");
578  for (i = 0; i < c->nofElts; i++) {
579  printf("elt %d: ", i);
580  if (IS_NOT_ACTIVE_ELT(i)) {
581  printf("na\n");
582  continue;
583  }
584 
585  a = (int *)Rast3d_cache_elt_ptr(c, c->names[i]);
586  /*Rast3d_cache_get_elt (c, c->names[i], a); */
587  printf("name %d val %d %s\n", c->names[i], a[17],
588  (IS_LOCKED_ELT(i) ? "locked" :
589  IS_UNLOCKED_ELT(i) ? "unlocked" : ""));
590  }
591  printf("\n--------------------------------\n");
592 
593  if (al)
595 }
596 
597 /*---------------------------------------------------------------------------*/
598 
599 static int cache_test_flush_fun(int name, const void *eltPtr, void *data)
600 {
601  printf("flushing name %d value %d\n", name, ((const int *)eltPtr)[17]);
602  return 0;
603 }
604 
605 /*---------------------------------------------------------------------------*/
606 
607 typedef struct
608 {
609 
610  int *value;
611  int size;
612 
613 } cache_test_data_type;
614 
615 static int cache_test_load_fun(int name, void *eltPtr, void *data)
616 {
617  const void *src;
618 
619  printf("loading name %d value %d\n", name,
620  ((cache_test_data_type *) data)->value[17]);
621 
622  src = ((cache_test_data_type *) data)->value;
623  memcpy(eltPtr, src, ((cache_test_data_type *) data)->size);
624 
625  return 0;
626 }
627 
628 /*---------------------------------------------------------------------------*/
629 
630 static cache_test_data_type ctd;
631 
632 static void cache_test_add(void *c, int name, int val)
633 {
634  static int firstTime = 1;
635 
636  if (firstTime) {
637  ctd.value = Rast3d_malloc(((RASTER3D_cache *) c)->eltSize * sizeof(int));
638  firstTime = 0;
639  }
640 
641  ctd.value[17] = val;
642  ctd.size = ((RASTER3D_cache *) c)->eltSize;
643 
644  Rast3d_cache_load(c, name);
645 }
646 
647 /*---------------------------------------------------------------------------*/
648 
649 int MAIN()
650 {
651  void *c;
652 
653  c = Rast3d_cache_new(3, 76 * sizeof(int), 100000,
654  cache_test_flush_fun, NULL, cache_test_load_fun, &ctd);
655 
657  cache_test_print(c);
658  cache_test_add(c, 1111, -11);
659  cache_test_print(c);
660  cache_test_add(c, 2222, -22);
661  cache_test_print(c);
662  cache_test_add(c, 3333, -33);
663  cache_test_print(c);
664  cache_test_add(c, 4444, -44);
665  cache_test_print(c);
667  cache_test_print(c);
668  Rast3d_cache_load(c, 2222);
669  cache_test_print(c);
670  cache_test_add(c, 5555, -55);
671  cache_test_print(c);
672  cache_test_add(c, 6666, -66);
673  cache_test_print(c);
674  cache_test_add(c, 7777, -77);
675  cache_test_print(c);
676  cache_test_add(c, 8888, -88);
677  cache_test_print(c);
678  cache_test_add(c, 9999, -99);
679  cache_test_print(c);
680  Rast3d_cache_flush(c, 9999);
681  cache_test_print(c);
683  cache_test_print(c);
684  cache_test_add(c, 1111, -11);
685  cache_test_print(c);
686  cache_test_add(c, 2222, -22);
687  cache_test_print(c);
688  cache_test_add(c, 3333, -33);
689  cache_test_print(c);
691  cache_test_print(c);
692  cache_test_add(c, 1111, -11);
693  cache_test_print(c);
694  cache_test_add(c, 2222, -22);
695  cache_test_print(c);
696  cache_test_add(c, 3333, -33);
697  cache_test_print(c);
698 
699  return 0;
700 }
char * locks
Definition: raster3d.h:199
void Rast3d_cache_reset(RASTER3D_cache *c)
Definition: cache1.c:34
#define IS_NOT_IN_QUEUE_ELT(elt)
Definition: cache1.c:16
void Rast3d_cache_dispose(RASTER3D_cache *c)
Definition: cache1.c:65
int Rast3d_cache_remove_all(RASTER3D_cache *c)
Definition: cache1.c:432
void * hash
Definition: raster3d.h:218
void * Rast3d_malloc(int)
Same as malloc (nBytes), except that in case of error Rast3d_error() is invoked.
void * Rast3d_cache_hash_new(int)
Definition: cachehash.c:51
char * dst
Definition: lz4.h:599
void Rast3d_cache_set_remove_fun(RASTER3D_cache *c, int(*eltRemoveFun)(), void *eltRemoveFunData)
Definition: cache1.c:142
int Rast3d_cache_flush(RASTER3D_cache *c, int name)
Definition: cache1.c:420
#define NULL
Definition: ccmath.h:32
int Rast3d_cache_load(RASTER3D_cache *c, int name)
Definition: cache1.c:515
int(* eltLoadFun)()
Definition: raster3d.h:214
void Rast3d_cache_set_load_fun(RASTER3D_cache *c, int(*eltLoadFun)(), void *eltLoadFunData)
Definition: cache1.c:152
#define IS_ACTIVE_ELT(elt)
Definition: cache1.c:12
void Rast3d_cache_hash_load_name(Rast3d_cache_hash *, int, int)
Definition: cachehash.c:92
void Rast3d_fatal_error(const char *,...) __attribute__((format(printf
int Rast3d_cache_unlock(RASTER3D_cache *c, int name)
Definition: cache1.c:302
void Rast3d_cache_hash_reset(Rast3d_cache_hash *)
Definition: cachehash.c:25
int Rast3d_cache_put_elt(RASTER3D_cache *c, int name, const void *src)
Definition: cache1.c:544
void Rast3d_error(const char *,...) __attribute__((format(printf
#define ONE_UNLOCKED_ELT_ONLY
Definition: cache1.c:29
void Rast3d_cache_hash_dispose(Rast3d_cache_hash *)
Definition: cachehash.c:37
#define IS_NOT_ACTIVE_ELT(elt)
Definition: cache1.c:13
#define IS_LOCKED_ELT(elt)
Definition: cache1.c:14
int(* eltRemoveFun)()
Definition: raster3d.h:210
int Rast3d_cache_lock_all(RASTER3D_cache *c)
Definition: cache1.c:339
void * Rast3d_cache_elt_ptr(RASTER3D_cache *c, int name)
Definition: cache1.c:465
void Rast3d_cache_autolock_on(RASTER3D_cache *c)
Definition: cache1.c:352
#define ARE_MIN_UNLOCKED
Definition: cache1.c:30
#define IS_IN_QUEUE_ELT(elt)
Definition: cache1.c:17
void Rast3d_cache_lock_intern(RASTER3D_cache *c, int index)
Definition: cache1.c:291
#define LOCK_ELT(elt)
Definition: cache1.c:22
int Rast3d_cache_hash_name2index(Rast3d_cache_hash *, int)
Definition: cachehash.c:106
void Rast3d_cache_set_min_unlock(RASTER3D_cache *c, int nofMinUnLocked)
Definition: cache1.c:366
int Rast3d_cache_get_elt(RASTER3D_cache *c, int name, void *dst)
Definition: cache1.c:527
#define DEACTIVATE_ELT(elt)
Definition: cache1.c:19
int Rast3d_cache_lock(RASTER3D_cache *c, int name)
Definition: cache1.c:266
int Rast3d_cache_unlock_all(RASTER3D_cache *c)
Definition: cache1.c:323
int read_fn(int, void *, void *)
Definition: raster3d.h:255
#define UNLOCK_ELT(elt)
Definition: cache1.c:25
void Rast3d_cache_autolock_off(RASTER3D_cache *c)
Definition: cache1.c:359
void * eltRemoveFunData
Definition: raster3d.h:212
int Rast3d_cache_flush_all(RASTER3D_cache *c)
Definition: cache1.c:449
void * Rast3d_cache_new(int nofElts, int sizeOfElts, int nofNames, int(*eltRemoveFun)(), void *eltRemoveFunData, int(*eltLoadFun)(), void *eltLoadFunData)
Definition: cache1.c:88
const char * name
Definition: named_colr.c:7
char * elts
Definition: raster3d.h:193
void Rast3d_cache_hash_remove_name(Rast3d_cache_hash *, int)
Definition: cachehash.c:77
#define IS_UNLOCKED_ELT(elt)
Definition: cache1.c:15
void * Rast3d_cache_new_read(int nofElts, int sizeOfElts, int nofNames, read_fn *eltLoadFun, void *eltLoadFunData)
Definition: cache1.c:161
int Rast3d_cache_remove_elt(RASTER3D_cache *c, int name)
Definition: cache1.c:408
int MAIN()
Definition: cache1.c:649
void * eltLoadFunData
Definition: raster3d.h:215
void Rast3d_free(void *)
Same as free (ptr).