PGROUTING  2.5
pgr_alloc.hpp File Reference
#include <string>
#include <cstring>
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

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 68 of file pgr_alloc.hpp.

References SPI_palloc(), and SPI_repalloc().

Referenced by alpha_shape(), do_pgr_articulationPoints(), do_pgr_astarManyToMany(), do_pgr_bdAstar(), do_pgr_bdDijkstra(), do_pgr_biconnectedComponents(), do_pgr_bridges(), do_pgr_connectedComponents(), do_pgr_dijkstraTRSP(), do_pgr_dijkstraVia(), do_pgr_driving_many_to_dist(), do_pgr_edge_disjoint_paths(), do_pgr_eucledianTSP(), do_pgr_ksp(), do_pgr_many_to_many_dijkstra(), do_pgr_many_withPointsDD(), do_pgr_max_flow(), do_pgr_maximum_cardinality_matching(), do_pgr_pickDeliver(), do_pgr_pickDeliverEuclidean(), do_pgr_strongComponents(), do_pgr_tsp(), do_pgr_withPoints(), do_pgr_withPointsKsp(), get_postgres_result(), Pgr_allpairs< G >::make_result(), and pgr_msg().

68  {
69  if (!ptr) {
70  ptr = static_cast<T*>(SPI_palloc(size * sizeof(T)));
71  } else {
72  ptr = static_cast<T*>(SPI_repalloc(ptr, size * sizeof(T)));
73  }
74  return ptr;
75 }
void * SPI_palloc(size_t size)
void * SPI_repalloc(void *pointer, size_t size)

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename T >
T* pgr_free ( T *  ptr)
char* pgr_msg ( const std::string &  msg)

Definition at line 29 of file pgr_alloc.cpp.

References pgr_alloc().

Referenced by do_pgr_articulationPoints(), do_pgr_astarManyToMany(), do_pgr_bdAstar(), do_pgr_bdDijkstra(), do_pgr_biconnectedComponents(), do_pgr_bridges(), do_pgr_connectedComponents(), do_pgr_contractGraph(), do_pgr_dijkstraTRSP(), do_pgr_dijkstraVia(), do_pgr_driving_many_to_dist(), do_pgr_edge_disjoint_paths(), do_pgr_eucledianTSP(), do_pgr_lineGraph(), do_pgr_many_to_many_dijkstra(), do_pgr_many_withPointsDD(), do_pgr_max_flow(), do_pgr_maximum_cardinality_matching(), do_pgr_pickDeliver(), do_pgr_pickDeliverEuclidean(), do_pgr_strongComponents(), do_pgr_tsp(), do_pgr_withPoints(), and pgr_free().

29  {
30  char* duplicate = NULL;
31  duplicate = pgr_alloc(msg.size() + 1, duplicate);
32  memcpy(duplicate, msg.c_str(), msg.size());
33  duplicate[msg.size()] = '\0';
34  return duplicate;
35 }
T * pgr_alloc(std::size_t size, T *ptr)
allocates memory
Definition: pgr_alloc.hpp:68

Here is the call graph for this function:

Here is the caller graph for this function:

void* SPI_palloc ( size_t  size)

Referenced by pgr_alloc().

Here is the caller graph for this function:

void SPI_pfree ( void *  pointer)

Referenced by pgr_free().

Here is the caller graph for this function:

void* SPI_repalloc ( void *  pointer,
size_t  size 
)

Referenced by pgr_alloc().

Here is the caller graph for this function: