diff options
author | Nick Wellnhofer <[email protected]> | 2015-06-07 17:44:11 +0200 |
---|---|---|
committer | Nick Wellnhofer <[email protected]> | 2015-06-07 21:42:15 +0200 |
commit | 0641c5e4e9727ddde0d2be1aebe3fd7009d010f5 (patch) | |
tree | b3f9402e18ef67eb17a61f949f524b9a3cbda54a /src/buffer.h | |
parent | 54abb08e615ab4d094b37ce3102df81779ee2c7a (diff) |
Helper to safely call strlen
Diffstat (limited to 'src/buffer.h')
-rw-r--r-- | src/buffer.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/buffer.h b/src/buffer.h index f9696e0..babd051 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -3,6 +3,7 @@ #include <stddef.h> #include <stdarg.h> +#include <string.h> #include <limits.h> #include "config.h" @@ -82,6 +83,11 @@ cmark_strbuf_check_bufsize(size_t size) { return (bufsize_t)size; } +static inline bufsize_t +cmark_strbuf_safe_strlen(const char *str) { + return cmark_strbuf_check_bufsize(strlen(str)); +} + #ifdef __cplusplus } #endif |