GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-b4e4cb0fe9
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 GIS 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  */
33 
35 {
36  int i;
37 
38  if (SEG->open != 1)
39  return -1;
40 
41  for (i = 0; i < SEG->nseg; i++)
42  G_free(SEG->scb[i].buf);
43  G_free(SEG->scb);
44 
45  G_free(SEG->freeslot);
46  G_free(SEG->agequeue);
47  G_free(SEG->load_idx);
48 
49  SEG->open = 0;
50 
51  return 1;
52 }
void G_free(void *)
Free allocated memory.
Definition: gis/alloc.c:150
int Segment_release(SEGMENT *SEG)
Free memory allocated to segment.
char * buf
Definition: segment.h:46
int * freeslot
Definition: segment.h:53
struct aq * agequeue
Definition: segment.h:54
int * load_idx
Definition: segment.h:51
struct SEGMENT::scb * scb
int nseg
Definition: segment.h:57
int open
Definition: segment.h:20