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