summaryrefslogtreecommitdiff
path: root/string.h
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-12-10 21:39:38 +0000
committerpeter1138 <peter1138@openttd.org>2006-12-10 21:39:38 +0000
commit4f7dc6b0f2d3ddaa7b8cef5711bf420044c6b733 (patch)
treebd63bedcba5acc5ae1fa0464d2cd8eb64a321121 /string.h
parent8e26cfb157420959fe3cde0c511d81089335fb74 (diff)
downloadopenttd-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.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/string.h b/string.h
index d5f637719..2dbc06eee 100644
--- a/string.h
+++ b/string.h
@@ -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;
/**