PGROUTING  2.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pgr_alloc.hpp File Reference
#include "c_common/postgres_connection.h"
#include "utils/palloc.h"
#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)
 

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

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().

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

Here is the caller graph for this function:

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(), and do_pgr_withPoints().

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:64

Here is the call graph for this function:

Here is the caller graph for this function: