vrpRouting  0.3
pgr_alloc.cpp
Go to the documentation of this file.
1 /*PGR-GNU*****************************************************************
2 File: pgr_palloc.cpp
3 
4 Copyright (c) 2015 pgRouting developers
6 
7 Developer:
8 Copyright (c) 2015 Celia Virginia Vergara Castillo
9 
10 ------
11 
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16 
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21 
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 
26  ********************************************************************PGR-GNU*/
27 
28 #include "c_common/pgr_alloc.hpp"
29 #include <cstring>
30 #include <string>
31 
32 char *
33 pgr_msg(const std::string &msg) {
34  char* duplicate = nullptr;
35  duplicate = pgr_alloc(msg.size() + 1, duplicate);
36  memcpy(duplicate, msg.c_str(), msg.size());
37  duplicate[msg.size()] = '\0';
38  return duplicate;
39 }
40 
pgr_alloc
T * pgr_alloc(std::size_t size, T *ptr)
allocates memory
Definition: pgr_alloc.hpp:66
pgr_msg
char * pgr_msg(const std::string &msg)
Definition: pgr_alloc.cpp:33
pgr_alloc.hpp