MCPcopy Create free account
hub / github.com/apache/trafficserver / localize

Method localize

include/proxy/hdrs/HdrHeap.h:250–264  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

allocate_strMethod · 0.95
memcpyFunction · 0.50
lengthMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected