From 0641c5e4e9727ddde0d2be1aebe3fd7009d010f5 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 7 Jun 2015 17:44:11 +0200 Subject: Helper to safely call strlen --- src/buffer.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/buffer.h') 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 #include +#include #include #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 -- cgit v1.2.3