PGROUTING  3.2
pgr_alloc.hpp File Reference
#include <string>
Include dependency graph for pgr_alloc.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename T >
T * pgr_alloc (std::size_t size, T *ptr)
 allocates memory More...
 
template<typename T >
T * pgr_free (T *ptr)
 
char * pgr_msg (const std::string &msg)
 
void * SPI_palloc (size_t size)
 
void SPI_pfree (void *pointer)
 
void * SPI_repalloc (void *pointer, size_t size)
 

Function Documentation

◆ pgr_alloc()

template<typename T >
pgr_alloc ( std::size_t  size,
T *  ptr 
)

allocates memory

  • Does a malloc or realloc depending on the ptr value
  • To be used only on C++ code
  • To be used when returning results to postgres
  • free must occur in the C code
Parameters
[in]size
[in]ptr
Returns
pointer to the first byte of allocated space

Definition at line 66 of file pgr_alloc.hpp.

66  {
67  if (!ptr) {
68  ptr = static_cast<T*>(SPI_palloc(size * sizeof(T)));
69  } else {
70  ptr = static_cast<T*>(SPI_repalloc(ptr, size * sizeof(T)));
71  }
72  return ptr;
73 }

References SPI_palloc(), and SPI_repalloc().

Referenced by do_alphaShape(), do_pgr_articulationPoints(), do_pgr_astarManyToMany(), do_pgr_bdAstar(), do_pgr_bdDijkstra(), do_pgr_bellman_ford(), do_pgr_bellman_ford_neg(), do_pgr_biconnectedComponents(), do_pgr_binaryBreadthFirstSearch(), do_pgr_bipartite(), do_pgr_boyerMyrvold(), do_pgr_breadthFirstSearch(), do_pgr_bridges(), do_pgr_combinations_dijkstra(), do_pgr_connectedComponents(), do_pgr_dagShortestPath(), do_pgr_depthFirstSearch(), do_pgr_dijkstraVia(), do_pgr_directedChPP(), do_pgr_driving_many_to_dist(), do_pgr_edge_disjoint_paths(), do_pgr_edwardMoore(), do_pgr_euclideanTSP(), do_pgr_kruskal(), do_pgr_ksp(), do_pgr_LTDTree(), do_pgr_makeConnected(), do_pgr_many_to_many_dijkstra(), do_pgr_many_withPointsDD(), do_pgr_max_flow(), do_pgr_maximum_cardinality_matching(), do_pgr_minCostMaxFlow(), do_pgr_pickDeliver(), do_pgr_pickDeliverEuclidean(), do_pgr_prim(), do_pgr_randomSpanningTree(), do_pgr_sequentialVertexColoring(), do_pgr_stoerWagner(), do_pgr_strongComponents(), do_pgr_topologicalSort(), do_pgr_tsp(), do_pgr_turnRestrictedPath(), do_pgr_withPoints(), do_pgr_withPointsKsp(), do_trsp(), get_postgres_result(), anonymous_namespace{contractGraph_driver.cpp}::get_postgres_result(), get_turn_penalty_postgres_result(), Pgr_allpairs< G >::make_result(), and pgr_msg().

◆ pgr_free()

◆ pgr_msg()

char* pgr_msg ( const std::string &  msg)

Definition at line 30 of file pgr_alloc.cpp.

30  {
31  char* duplicate = NULL;
32  duplicate = pgr_alloc(msg.size() + 1, duplicate);
33  memcpy(duplicate, msg.c_str(), msg.size());
34  duplicate[msg.size()] = '\0';
35  return duplicate;
36 }

References pgr_alloc().

Referenced by do_alphaShape(), do_pgr_articulationPoints(), do_pgr_astarManyToMany(), do_pgr_bdAstar(), do_pgr_bdDijkstra(), do_pgr_bellman_ford(), do_pgr_bellman_ford_neg(), do_pgr_biconnectedComponents(), do_pgr_binaryBreadthFirstSearch(), do_pgr_bipartite(), do_pgr_boyerMyrvold(), do_pgr_breadthFirstSearch(), do_pgr_bridges(), do_pgr_combinations_dijkstra(), do_pgr_connectedComponents(), do_pgr_contractGraph(), do_pgr_dagShortestPath(), do_pgr_depthFirstSearch(), do_pgr_dijkstraVia(), do_pgr_directedChPP(), do_pgr_driving_many_to_dist(), do_pgr_edge_disjoint_paths(), do_pgr_edwardMoore(), do_pgr_euclideanTSP(), do_pgr_floydWarshall(), do_pgr_isPlanar(), do_pgr_johnson(), do_pgr_kruskal(), do_pgr_ksp(), do_pgr_lineGraph(), do_pgr_lineGraphFull(), do_pgr_LTDTree(), do_pgr_makeConnected(), do_pgr_many_to_many_dijkstra(), do_pgr_many_withPointsDD(), do_pgr_max_flow(), do_pgr_maximum_cardinality_matching(), do_pgr_minCostMaxFlow(), do_pgr_pickDeliver(), do_pgr_pickDeliverEuclidean(), do_pgr_prim(), do_pgr_randomSpanningTree(), do_pgr_sequentialVertexColoring(), do_pgr_stoerWagner(), do_pgr_strongComponents(), do_pgr_topologicalSort(), do_pgr_transitiveClosure(), do_pgr_tsp(), do_pgr_turnRestrictedPath(), do_pgr_withPoints(), do_pgr_withPointsKsp(), do_trsp(), get_name(), get_new_queries(), and get_order().

◆ SPI_palloc()

void* SPI_palloc ( size_t  size)

Referenced by pgr_alloc().

◆ SPI_pfree()

void SPI_pfree ( void *  pointer)

Referenced by pgr_free().

◆ SPI_repalloc()

void* SPI_repalloc ( void *  pointer,
size_t  size 
)

Referenced by pgr_alloc().

pgr_alloc
T * pgr_alloc(std::size_t size, T *ptr)
allocates memory
Definition: pgr_alloc.hpp:66
SPI_repalloc
void * SPI_repalloc(void *pointer, size_t size)
SPI_pfree
void SPI_pfree(void *pointer)
SPI_palloc
void * SPI_palloc(size_t size)