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

Function Strlen_

src/strutil.c:81–98  ·  view source on GitHub ↗

strlen() but returns unsigned and panics if string is unreasonably long; used by dlb as well as by nethack */

Source from the content-addressed store, hash-verified

79/* strlen() but returns unsigned and panics if string is unreasonably long;
80 used by dlb as well as by nethack */
81unsigned
82Strlen_(
83 const char *str,
84 const char *file,
85 int line)
86{
87 const char *p;
88 size_t len;
89
90 /* strnlen(str, LARGEST_INT) w/o requiring posix.1 headers or libraries */
91 for (p = str, len = 0; len < LARGEST_INT; ++len)
92 if (*p++ == '\0')
93 break;
94
95 if (len == LARGEST_INT)
96 panic("%s:%d string too long", file, line);
97 return (unsigned) len;
98}
99
100staticfn boolean pmatch_internal(const char *, const char *, boolean,
101 const char *);

Callers

nothing calls this directly

Calls 1

panicFunction · 0.50

Tested by

no test coverage detected