mirror of
https://github.com/lua/lua
synced 2026-09-26 16:17:11 +03:00
Cleaner definition for 'TString'
Use a variable-sized array to store string contents at the end of a structure 'TString', instead of raw memory.
This commit is contained in:
parent
0be57b9b6d
commit
9514abc2da
2 changed files with 8 additions and 5 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue