Browse Source

new not set state for arrays

Kajetan Johannes Hammerle 3 years ago
parent
commit
1694aa3622
1 changed files with 3 additions and 3 deletions
  1. 3 3
      vm/Arrays.c

+ 3 - 3
vm/Arrays.c

@@ -25,7 +25,7 @@ void asDelete(SnuviArrays* as) {
 
 static void aInitArray(SnuviArray* a, int previous, int next) {
     a->size = 0;
-    a->length = 0;
+    a->length = -1;
     a->next = next;
     a->previous = previous;
     a->data = NULL;
@@ -103,7 +103,7 @@ int asAllocate(SnuviArrays* as, int typeSize, int length) {
 }
 
 SnuviArray* asGet(SnuviArrays* as, int p) {
-    if(p < 0 || p >= as->capacity || as->data[p].size == 0) {
+    if(p < 0 || p >= as->capacity || as->data[p].length == -1) {
         return NULL;
     }
     return as->data + p;
@@ -131,7 +131,7 @@ void asDeleteArray(SnuviArrays* as, SnuviArray* a, int p) {
     allocatedBytes -= a->size;
     a->previous = -1;
     a->size = 0;
-    a->length = 0;
+    a->length = -1;
     free(a->data);
     a->data = NULL;
 }