External strings

Strings can use external buffers to store their contents.
This commit is contained in:
Roberto Ierusalimschy
2023-11-09 17:05:42 -03:00
parent 7f4906f565
commit 024f9064f1
9 changed files with 195 additions and 14 deletions

View File

@@ -382,6 +382,12 @@ typedef struct GCObject {
#define setsvalue2n setsvalue
/* Kinds of long strings (stored in 'shrlen') */
#define LSTRREG -1 /* regular long string */
#define LSTRFIX -2 /* fixed external long string */
#define LSTRMEM -3 /* external long string with deallocation */
/*
** Header for a string value.
*/
@@ -395,6 +401,8 @@ typedef struct TString {
struct TString *hnext; /* linked list for hash table */
} u;
char *contents; /* pointer to content in long strings */
lua_Alloc falloc; /* deallocation function for external strings */
void *ud; /* user data for external strings */
} TString;