MCPcopy Index your code
hub / github.com/MapServer/MapServer / strlcat

Function strlcat

mapstring.c:141–166  ·  view source on GitHub ↗

* Appends src to string dst of size siz (unlike strncat, siz is the * full size of dst, not space left). At most siz-1 characters * will be copied. Always NUL terminates (unless siz <= strlen(dst)). * Returns strlen(src) + MIN(siz, strlen(initial dst)). * If retval >= siz, truncation occurred. */

Source from the content-addressed store, hash-verified

139 * If retval >= siz, truncation occurred.
140 */
141size_t strlcat(char *dst, const char *src, size_t siz)
142{
143 register char *d = dst;
144 register const char *s = src;
145 register size_t n = siz;
146 size_t dlen;
147
148 /* Find the end of dst and adjust bytes left but don't go past end */
149 while (n-- != 0 && *d != '\0')
150 d++;
151 dlen = d - dst;
152 n = siz - dlen;
153
154 if (n == 0)
155 return(dlen + strlen(s));
156 while (*s != '\0') {
157 if (n != 1) {
158 *d++ = *s;
159 n--;
160 }
161 s++;
162 }
163 *d = '\0';
164
165 return(dlen + (s - src));/* count does not include NUL */
166}
167#endif
168
169#ifdef NEED_STRLCPY

Calls

no outgoing calls

Tested by

no test coverage detected