diff options
author | peter1138 <peter1138@openttd.org> | 2006-12-10 21:39:38 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2006-12-10 21:39:38 +0000 |
commit | 4f7dc6b0f2d3ddaa7b8cef5711bf420044c6b733 (patch) | |
tree | bd63bedcba5acc5ae1fa0464d2cd8eb64a321121 /string.h | |
parent | 8e26cfb157420959fe3cde0c511d81089335fb74 (diff) | |
download | openttd-4f7dc6b0f2d3ddaa7b8cef5711bf420044c6b733.tar.xz |
(svn r7475) -Fix (r7348): sanity check NewGRF action 8 strings for null terminator
Diffstat (limited to 'string.h')
-rw-r--r-- | string.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -46,6 +46,16 @@ typedef enum CharSetFilter { /** Convert the given string to lowercase, only works with ASCII! */ void strtolower(char *str); + +/** Get the length of a string, within a limited buffer */ +static inline int ttd_strnlen(const char *str, int maxlen) +{ + const char *t; + for (t = str; *t != '\0' && t - str < maxlen; t++); + return t - str; +} + + typedef uint32 WChar; /** |