GRASS 8 Programmer's Manual 8.6.0dev(2026)-56a9afeb9f
Loading...
Searching...
No Matches
segment/release.c
Go to the documentation of this file.
1/**
2 * \file lib/segment/release.c
3 *
4 * \brief Segment release routines.
5 *
6 * This program is free software under the GNU General Public License
7 * (>=v2). Read the file COPYING that comes with GRASS for details.
8 *
9 * \author GRASS Development Team
10 *
11 * \date 2005-2009
12 */
13
14#include <stdlib.h>
15#include <grass/gis.h>
16#include "local_proto.h"
17
18/**
19 * \fn int Segment_release (SEGMENT *SEG)
20 *
21 * \brief Free memory allocated to segment.
22 *
23 * Releases the allocated memory associated with the segment file
24 * <b>seg</b>.
25 *
26 * <b>Note:</b> Does not close the file. Does not flush the data which
27 * may be pending from previous <i>Segment_put()</i> calls.
28 *
29 * \param[in,out] SEG segment
30 * \return 1 if successful
31 * \return -1 if SEGMENT is not available (not open)
32 */
34{
35 int i;
36
37 if (SEG->open != 1)
38 return -1;
39
40 for (i = 0; i < SEG->nseg; i++)
41 G_free(SEG->scb[i].buf);
42 G_free(SEG->scb);
43
44 G_free(SEG->freeslot);
45 G_free(SEG->agequeue);
46 G_free(SEG->load_idx);
47
48 SEG->open = 0;
49
50 return 1;
51}
void G_free(void *)
Free allocated memory.
Definition gis/alloc.c:147
int Segment_release(SEGMENT *SEG)
Free memory allocated to segment.