GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
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 
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 }
int nseg
Definition: segment.h:58
int open
Definition: segment.h:21
void G_free(void *)
Free allocated memory.
Definition: gis/alloc.c:149
int * load_idx
Definition: segment.h:52
char * buf
Definition: segment.h:47
struct aq * agequeue
Definition: segment.h:55
int Segment_release(SEGMENT *SEG)
Free memory allocated to segment.
int * freeslot
Definition: segment.h:54
struct SEGMENT::scb * scb