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.
| 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. |
| 21 | static 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. |
| 29 | auto &pad(auto &vec1, auto const &vec2) |
no outgoing calls
no test coverage detected