GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
color_free.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <grass/gis.h>
3 
4 
17 int G_free_colors(struct Colors *colors)
18 {
19  G__color_reset(colors);
20  G_init_colors(colors);
21 
22  return 0;
23 }
24 
25 /*******************************************
26  * G__color* routines only to be used by other routines in this
27  * library
28  *******************************************/
29 
30 int G__color_free_rules(struct _Color_Info_ *cp)
31 {
32  struct _Color_Rule_ *rule, *next;
33 
34  for (rule = cp->rules; rule; rule = next) {
35  next = rule->next;
36  G_free(rule);
37  }
38  cp->rules = NULL;
39 
40  return 0;
41 }
42 
43 int G__color_free_lookup(struct _Color_Info_ *cp)
44 {
45  if (cp->lookup.active) {
46  G_free(cp->lookup.red);
47  G_free(cp->lookup.blu);
48  G_free(cp->lookup.grn);
49  G_free(cp->lookup.set);
50  cp->lookup.active = 0;
51  }
52 
53  return 0;
54 }
55 
56 int G__color_free_fp_lookup(struct _Color_Info_ *cp)
57 {
58  if (cp->fp_lookup.active) {
59  G_free(cp->fp_lookup.vals);
60  G_free(cp->fp_lookup.rules);
61  cp->fp_lookup.active = 0;
62  cp->fp_lookup.nalloc = 0;
63  }
64 
65  return 0;
66 }
67 
68 int G__color_reset(struct Colors *colors)
69 {
70  G__color_free_lookup(&colors->fixed);
71  G__color_free_lookup(&colors->modular);
72  G__color_free_rules(&colors->fixed);
73  G__color_free_rules(&colors->modular);
74  colors->version = 0;
75  /* this routine should NOT init the colors */
76 
77  return 0;
78 }
void G_free(void *buf)
Free allocated memory.
Definition: gis/alloc.c:142
int G__color_free_rules(struct _Color_Info_ *cp)
Definition: color_free.c:30
int G__color_reset(struct Colors *colors)
Definition: color_free.c:68
int G__color_free_fp_lookup(struct _Color_Info_ *cp)
Definition: color_free.c:56
int G_free_colors(struct Colors *colors)
free color structure memory
Definition: color_free.c:17
return NULL
Definition: dbfopen.c:1394
int G__color_free_lookup(struct _Color_Info_ *cp)
Definition: color_free.c:43
G_init_colors(colors)