Store string length

Strings are still null-terminated so that they can be treated as C strings.
This commit is contained in:
Evan Shaw
2015-01-08 09:53:32 +13:00
parent 0d099933d6
commit 3fd348e6c1
2 changed files with 2 additions and 0 deletions

View File

@ -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);
}

View File

@ -108,6 +108,7 @@ DECLARE_BUFFER(Value, Value);
typedef struct
{
Obj obj;
size_t length; // not including null terminator
char value[];
} ObjString;