2 * SPDX-License-Identifier: MIT
4 * Copyright (C) 2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 #ifndef _BABELTRACE_COMPAT_STRING_H
8 #define _BABELTRACE_COMPAT_STRING_H
15 size_t bt_strnlen(const char *str
, size_t max
)
17 return strnlen(str
, max
);
21 size_t bt_strnlen(const char *str
, size_t max
)
26 end
= memchr(str
, 0, max
);
29 ret
= (size_t) (end
- str
);
36 #endif /* HAVE_STRNLEN */
40 char *bt_strndup(const char *s
, size_t n
)
46 char *bt_strndup(const char *s
, size_t n
)
57 navail
= strlen(s
) + 1;
58 if ((n
+ 1) < navail
) {
67 memcpy(ret
, s
, navail
);
68 ret
[navail
- 1] = '\0';
72 #endif /* HAVE_STRNDUP */
74 #endif /* _BABELTRACE_COMPAT_STRING_H */
This page took 0.030395 seconds and 4 git commands to generate.