GRASS 8 Programmer's Manual
8.5.0dev(2025)-d272f2f102
segment/close.c
Go to the documentation of this file.
1
/**
2
* \file lib/segment/close.c
3
*
4
* \brief Segment closing routine.
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 2018
12
*/
13
14
#include <
unistd.h
>
15
#include <
fcntl.h
>
16
#include <
grass/gis.h
>
17
#include <
grass/glocale.h
>
18
#include "local_proto.h"
19
20
/**
21
* \fn int Segment_close (SEGMENT *SEG)
22
*
23
* \brief Free memory allocated to segment, delete temp file.
24
*
25
* Releases the allocated memory associated with the segment file
26
* <b>seg</b> and deletes the temporary file.
27
*
28
* \param[in,out] SEG segment
29
* \return 1 if successful
30
* \return -1 if SEGMENT is not available (not open)
31
*/
32
int
Segment_close
(
SEGMENT
*SEG)
33
{
34
if
(SEG->
open
!= 1)
35
return
-1;
36
37
if
(SEG->
cache
) {
38
G_free
(SEG->
cache
);
39
}
40
else
{
41
Segment_release
(SEG);
42
close
(SEG->
fd
);
43
unlink
(SEG->
fname
);
44
45
SEG->
fd
= -1;
46
SEG->
fname
=
NULL
;
47
}
48
49
SEG->
open
= 0;
50
51
return
1;
52
}
NULL
#define NULL
Definition:
ccmath.h:32
G_free
void G_free(void *)
Free allocated memory.
Definition:
gis/alloc.c:147
Segment_release
int Segment_release(SEGMENT *)
Free memory allocated to segment.
Definition:
segment/release.c:33
fcntl.h
Header file for msvc/fcntl.c.
gis.h
glocale.h
Segment_close
int Segment_close(SEGMENT *SEG)
Free memory allocated to segment, delete temp file.
Definition:
segment/close.c:32
SEGMENT
Definition:
segment.h:19
SEGMENT::cache
char * cache
Definition:
segment.h:61
SEGMENT::open
int open
Definition:
segment.h:20
SEGMENT::fd
int fd
Definition:
segment.h:43
SEGMENT::fname
char * fname
Definition:
segment.h:42
unistd.h
unlink
#define unlink
Definition:
unistd.h:11
close
#define close
Definition:
unistd.h:8
lib
segment
close.c
Generated on Sun Aug 31 2025 07:00:43 for GRASS 8 Programmer's Manual by
1.9.1