Store string length
Strings are still null-terminated so that they can be treated as C strings.
This commit is contained in:
parent
0d099933d6
commit
3fd348e6c1
@ -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;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user