GRASS Programmer's Manual
6.4.1(2011)
|
00001 #include <stdlib.h> 00002 #include <grass/gis.h> 00003 00004 00017 int G_free_colors(struct Colors *colors) 00018 { 00019 G__color_reset(colors); 00020 G_init_colors(colors); 00021 00022 return 0; 00023 } 00024 00025 /******************************************* 00026 * G__color* routines only to be used by other routines in this 00027 * library 00028 *******************************************/ 00029 00030 int G__color_free_rules(struct _Color_Info_ *cp) 00031 { 00032 struct _Color_Rule_ *rule, *next; 00033 00034 for (rule = cp->rules; rule; rule = next) { 00035 next = rule->next; 00036 G_free(rule); 00037 } 00038 cp->rules = NULL; 00039 00040 return 0; 00041 } 00042 00043 int G__color_free_lookup(struct _Color_Info_ *cp) 00044 { 00045 if (cp->lookup.active) { 00046 G_free(cp->lookup.red); 00047 G_free(cp->lookup.blu); 00048 G_free(cp->lookup.grn); 00049 G_free(cp->lookup.set); 00050 cp->lookup.active = 0; 00051 } 00052 00053 return 0; 00054 } 00055 00056 int G__color_free_fp_lookup(struct _Color_Info_ *cp) 00057 { 00058 if (cp->fp_lookup.active) { 00059 G_free(cp->fp_lookup.vals); 00060 G_free(cp->fp_lookup.rules); 00061 cp->fp_lookup.active = 0; 00062 cp->fp_lookup.nalloc = 0; 00063 } 00064 00065 return 0; 00066 } 00067 00068 int G__color_reset(struct Colors *colors) 00069 { 00070 G__color_free_lookup(&colors->fixed); 00071 G__color_free_lookup(&colors->modular); 00072 G__color_free_rules(&colors->fixed); 00073 G__color_free_rules(&colors->modular); 00074 colors->version = 0; 00075 /* this routine should NOT init the colors */ 00076 00077 return 0; 00078 }