Working function to copy strings into a new heap Unlike the HDR_MOVE_STR macro, this function will call allocate_str which will update the new_heap to create more space if there is not originally sufficient space
| 248 | // allocate_str which will update the new_heap to create more space |
| 249 | // if there is not originally sufficient space |
| 250 | inline std::string_view |
| 251 | localize(const std::string_view &string) |
| 252 | { |
| 253 | auto length = string.length(); |
| 254 | if (length > 0) { |
| 255 | char *new_str = this->allocate_str(length); |
| 256 | if (new_str) { |
| 257 | memcpy(new_str, string.data(), length); |
| 258 | } else { |
| 259 | length = 0; |
| 260 | } |
| 261 | return {new_str, length}; |
| 262 | } |
| 263 | return {nullptr, 0}; |
| 264 | } |
| 265 | |
| 266 | // Sanity Check Functions |
| 267 | void sanity_check_strs(); |
nothing calls this directly
no test coverage detected