PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches
lwt_node_edges.c
Go to the documentation of this file.
1/**********************************************************************
2 *
3 * PostGIS - Spatial Types for PostgreSQL
4 * http://postgis.net
5 *
6 * PostGIS is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * PostGIS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with PostGIS. If not, see <http://www.gnu.org/licenses/>.
18 *
19 **********************************************************************
20 *
21 * Copyright (C) 2024 Sandro Santilli <strk@kbt.io>
22 *
23 **********************************************************************/
24
25#include "lwt_node_edges.h"
26
27void
29{
30 if ( star->numEdges ) {
31 if ( star->fields & LWT_COL_EDGE_GEOM )
32 _lwt_release_edges(star->edges, star->numEdges);
33 else
34 lwfree(star->edges);
35 }
36 lwfree(star);
37}
38
39/*
40 * @return NULL on error, calling lwerror, otherwise an object to
41 * be released with lwt_nodeEdges_release()
42 */
45{
46 LWT_NODE_EDGES *star = lwalloc(sizeof(LWT_NODE_EDGES));
47 star->numEdges = 1;
48 /* Get incident edges */
49 star->edges = lwt_be_getEdgeByNode( topo, &node_id, &(star->numEdges), fields );
50 if (star->numEdges == UINT64_MAX)
51 {
53 lwfree(star);
54 return NULL;
55 }
56 star->fields = fields;
57 return star;
58}
void * lwalloc(size_t size)
Definition lwutil.c:227
void lwfree(void *mem)
Definition lwutil.c:248
LWT_INT64 LWT_ELEMID
Identifier of topology element.
#define LWT_COL_EDGE_GEOM
void _lwt_release_edges(LWT_ISO_EDGE *edges, int num_edges)
LWT_ISO_EDGE * lwt_be_getEdgeByNode(LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, uint64_t *numelems, int fields)
#define PGTOPO_BE_ERROR()
LWT_NODE_EDGES * lwt_nodeEdges_loadFromDB(LWT_TOPOLOGY *topo, LWT_ELEMID node_id, int fields)
void lwt_nodeEdges_release(LWT_NODE_EDGES *star)
LWT_ISO_EDGE * edges