MCPcopy Index your code
hub / github.com/NetHack/NetHack / dupstr

Function dupstr

src/alloc.c:237–247  ·  view source on GitHub ↗

strdup() which uses our alloc() rather than libc's malloc(); not used when MONITOR_HEAP is enabled, but included unconditionally in case utility programs get built using a different setting for that */

Source from the content-addressed store, hash-verified

235 not used when MONITOR_HEAP is enabled, but included unconditionally
236 in case utility programs get built using a different setting for that */
237char *
238dupstr(const char *string)
239{
240 size_t len = strlen(string);
241
242 /* make sure len+1 doesn't overflow plain unsigned (for alloc()) */
243 if (len > (unsigned) (~0U - 1U))
244 panic("dupstr: string length overflow");
245
246 return strcpy((char *) alloc(len + 1), string);
247}
248
249#if 0 /* suppress this; if included, it will need a MONITOR_HEAP edition */
250

Callers 15

term_startupFunction · 0.85
init_hiliteFunction · 0.85
tty_add_menuFunction · 0.85
tty_end_menuFunction · 0.85
drawWornMethod · 0.85
mesg_add_lineFunction · 0.85
curs_add_invtFunction · 0.85
curses_copy_ofFunction · 0.85
new_resource_macroFunction · 0.85
load_default_resourcesFunction · 0.85
X11_display_fileFunction · 0.85
copy_ofFunction · 0.85

Calls 2

allocFunction · 0.70
panicFunction · 0.50

Tested by

no test coverage detected