MCPcopy Create free account
hub / github.com/PyVRP/PyVRP / duplicate

Function duplicate

pyvrp/cpp/ProblemData.cpp:21–26  ·  view source on GitHub ↗

Small local helper for what is essentially strdup() from the C23 standard, which my compiler does not (yet) have. See here for the actual recipe: https://stackoverflow.com/a/252802/4316405 (modified to use new instead of malloc). We do all this so we can use C-style strings, rather than C++'s std::string, which are much larger objects.

Source from the content-addressed store, hash-verified

19// malloc). We do all this so we can use C-style strings, rather than C++'s
20// std::string, which are much larger objects.
21static char *duplicate(char const *src)
22{
23 char *dst = new char[std::strlen(src) + 1]; // space for src + null
24 std::strcpy(dst, src);
25 return dst;
26}
27
28// Pad vec1 with zeroes to the size of vec1 and vec2, whichever is larger.
29auto &pad(auto &vec1, auto const &vec2)

Callers 4

ClientMethod · 0.85
ClientGroupMethod · 0.85
DepotMethod · 0.85
VehicleTypeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected