GRASS 8 Programmer's Manual 8.6.0dev(2026)-4bb960b182
Loading...
Searching...
No Matches
color_free.c
Go to the documentation of this file.
1/*!
2 * \file lib/raster/color_free.c
3 *
4 * \brief Raster Library - Free Colors structure
5 *
6 * SPDX-FileCopyrightText: 2001-2009 GRASS Development Team
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 *
9 * \author Original author CERL
10 */
11
12#include <stdlib.h>
13
14#include <grass/gis.h>
15#include <grass/raster.h>
16
17/*!
18 * \brief Free color structure memory
19 *
20 * The dynamically allocated memory associated with the <i>colors</i>
21 * structure is freed.
22 *
23 * <b>Note:</b> This routine may be used after Rast_read_colors() as well
24 * as after Rast_init_colors().
25 *
26 * \param colors pointer to Colors structure
27 */
28void Rast_free_colors(struct Colors *colors)
29{
30 Rast__color_reset(colors);
31 Rast_init_colors(colors);
32}
33
34/*!
35 \brief Free color rules structure
36
37 Note: Only for internal use.
38
39 \param cp pointer to _Color_Info structure
40 */
42{
43 struct _Color_Rule_ *rule, *next;
44
45 for (rule = cp->rules; rule; rule = next) {
46 next = rule->next;
47 G_free(rule);
48 }
49 cp->rules = NULL;
50}
51
52/*!
53 \brief Free color rules structure
54
55 Note: Only for internal use.
56
57 \param cp pointer to _Color_Info structure
58 */
60{
61 if (cp->lookup.active) {
62 G_free(cp->lookup.red);
63 G_free(cp->lookup.blu);
64 G_free(cp->lookup.grn);
65 G_free(cp->lookup.set);
66 cp->lookup.active = 0;
67 }
68}
69
70/*!
71 \brief Free color rules structure
72
73 Note: Only for internal use.
74
75 \param cp pointer to _Color_Info structure
76 */
78{
79 if (cp->fp_lookup.active) {
80 G_free(cp->fp_lookup.vals);
81 G_free(cp->fp_lookup.rules);
82 cp->fp_lookup.active = 0;
83 cp->fp_lookup.nalloc = 0;
84 }
85}
86
87/*!
88 \brief Reset colors structure
89
90 Note: Only for internal use.
91
92 This routine should NOT init the colors.
93
94 \param colors pointer to Colors structure
95 */
96void Rast__color_reset(struct Colors *colors)
97{
102 colors->version = 0;
103}
#define NULL
Definition ccmath.h:32
void Rast__color_reset(struct Colors *colors)
Reset colors structure.
Definition color_free.c:96
void Rast__color_free_lookup(struct _Color_Info_ *cp)
Free color rules structure.
Definition color_free.c:59
void Rast_free_colors(struct Colors *colors)
Free color structure memory.
Definition color_free.c:28
void Rast__color_free_rules(struct _Color_Info_ *cp)
Free color rules structure.
Definition color_free.c:41
void Rast__color_free_fp_lookup(struct _Color_Info_ *cp)
Free color rules structure.
Definition color_free.c:77
void G_free(void *)
Free allocated memory.
Definition gis/alloc.c:145
void Rast_init_colors(struct Colors *)
Initialize color structure.
Definition color_init.c:23
Definition gis.h:689
struct _Color_Info_ fixed
Definition gis.h:702
struct _Color_Info_ modular
Definition gis.h:703
int version
Definition gis.h:690
struct _Color_Rule_ * next
Definition gis.h:661