~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to lib/segment/close.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 GIS Development Team
 
10
 *
 
11
 * \date 2012
 
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
 
 
33
int Segment_close(SEGMENT *SEG)
 
34
{
 
35
    if (SEG->open != 1)
 
36
        return -1;
 
37
 
 
38
    Segment_release(SEG);
 
39
    close(SEG->fd);
 
40
    unlink(SEG->fname);
 
41
 
 
42
    SEG->fd = -1;
 
43
    SEG->fname = NULL;
 
44
 
 
45
    return 1;
 
46
}