summaryrefslogtreecommitdiff
path: root/lstring.h
diff options
context:
space:
mode:
Diffstat (limited to 'lstring.h')
-rw-r--r--lstring.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/lstring.h b/lstring.h
index 56896867..a413a9d3 100644
--- a/lstring.h
+++ b/lstring.h
@@ -19,7 +19,11 @@
#define MEMERRMSG "not enough memory"
-#define sizelstring(l) (sizeof(TString) + ((l) + 1) * sizeof(char))
+/*
+** Size of a TString: Size of the header plus space for the string
+** itself (including final '\0').
+*/
+#define sizelstring(l) (offsetof(TString, contents) + ((l) + 1) * sizeof(char))
#define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \
(sizeof(s)/sizeof(char))-1))