mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-11 22:28:45 +01:00
Store string length
Strings are still null-terminated so that they can be treated as C strings.
This commit is contained in:
@ -341,6 +341,7 @@ Value wrenNewUninitializedString(WrenVM* vm, size_t length)
|
||||
{
|
||||
ObjString* string = allocate(vm, sizeof(ObjString) + length + 1);
|
||||
initObj(vm, &string->obj, OBJ_STRING, vm->stringClass);
|
||||
string->length = length;
|
||||
|
||||
return OBJ_VAL(string);
|
||||
}
|
||||
|
||||
@ -108,6 +108,7 @@ DECLARE_BUFFER(Value, Value);
|
||||
typedef struct
|
||||
{
|
||||
Obj obj;
|
||||
size_t length; // not including null terminator
|
||||
char value[];
|
||||
} ObjString;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user