MCPcopy Create free account
hub / github.com/NetHack/NetHack / nhdupstr

Function nhdupstr

src/alloc.c:218–229  ·  view source on GitHub ↗

strdup() which uses our alloc() rather than libc's malloc(), with caller tracking */

Source from the content-addressed store, hash-verified

216/* strdup() which uses our alloc() rather than libc's malloc(),
217 with caller tracking */
218char *
219nhdupstr(const char *string, const char *file, int line)
220{
221 /* we've got some info about the caller, so use it instead of __func__ */
222 unsigned len = FITSuint_(strlen(string), file, line);
223
224 if (FITSuint_(len + 1, file, line) < len)
225 panic("nhdupstr: string length overflow, line %d of %s",
226 line, file);
227
228 return strcpy((char *) nhalloc(len + 1, file, line), string);
229}
230#undef dupstr
231
232#endif /* MONITOR_HEAP */

Callers

nothing calls this directly

Calls 3

FITSuint_Function · 0.85
nhallocFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected