MCPcopy Create free account
hub / github.com/GJDuck/e9patch / dupString

Function dupString

src/e9patch/e9json.cpp:153–165  ·  view source on GitHub ↗

* Duplicate a string. */

Source from the content-addressed store, hash-verified

151 * Duplicate a string.
152 */
153static const char *dupString(const char *str)
154{
155 static std::set<const char *, CStrCmp> cache;
156 auto i = cache.find(str);
157 if (i != cache.end())
158 return *i;
159
160 char *new_str = strdup(str);
161 if (new_str == nullptr)
162 error("failed to duplicate string \"%s\": %s", str, strerror(ENOMEM));
163 cache.insert(new_str);
164 return new_str;
165}
166
167/*
168 * Duplicate bytes.

Callers 6

makeMacroEntryFunction · 0.85
makeLabelEntryFunction · 0.85
makeDataEntryFunction · 0.85
parseMetadataFunction · 0.85
parseStringsFunction · 0.85
parseParamsFunction · 0.85

Calls 5

strdupFunction · 0.85
errorFunction · 0.85
strerrorFunction · 0.85
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected