diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-05-19 12:42:20 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-05-19 12:42:20 -0300 |
commit | 9514abc2da3525ef4314a8fcf70982ad07319e51 (patch) | |
tree | f3d30b28767cf1f3aedff7521ed1b83c9443c7cf /lstring.h | |
parent | 0be57b9b6d1a4ea8d41c9c9b9b434b4749ccbb27 (diff) | |
download | lua-9514abc2da3525ef4314a8fcf70982ad07319e51.tar.gz lua-9514abc2da3525ef4314a8fcf70982ad07319e51.tar.bz2 lua-9514abc2da3525ef4314a8fcf70982ad07319e51.zip |
Cleaner definition for 'TString'
Use a variable-sized array to store string contents at the end of a
structure 'TString', instead of raw memory.
Diffstat (limited to 'lstring.h')
-rw-r--r-- | lstring.h | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -19,7 +19,11 @@ | |||
19 | #define MEMERRMSG "not enough memory" | 19 | #define MEMERRMSG "not enough memory" |
20 | 20 | ||
21 | 21 | ||
22 | #define sizelstring(l) (sizeof(TString) + ((l) + 1) * sizeof(char)) | 22 | /* |
23 | ** Size of a TString: Size of the header plus space for the string | ||
24 | ** itself (including final '\0'). | ||
25 | */ | ||
26 | #define sizelstring(l) (offsetof(TString, contents) + ((l) + 1) * sizeof(char)) | ||
23 | 27 | ||
24 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ | 28 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ |
25 | (sizeof(s)/sizeof(char))-1)) | 29 | (sizeof(s)/sizeof(char))-1)) |