X-Git-Url: https://git.llucax.com/software/dgc/naive.git/blobdiff_plain/802aa7fc0eeb044538d371e936197752bbb53612..refs/heads/master:/gc/dynarray.d?ds=inline diff --git a/gc/dynarray.d b/gc/dynarray.d index f0d5218..bd387cf 100644 --- a/gc/dynarray.d +++ b/gc/dynarray.d @@ -106,7 +106,7 @@ public: if (new_capacity == 0) new_capacity = 4; // reallocate the memory with the new_capacity - T* new_data = cast(T*) realloc(this.data, new_capacity); + T* new_data = cast(T*) realloc(this.data, new_capacity * T.sizeof); if (new_data is null) onOutOfMemoryError(); this.data = new_data; @@ -153,19 +153,19 @@ private: DynArray!(int) array; assert (array.size == 0); assert (array.capacity == 0); - assert (array.data == null); + assert (array.data is null); foreach (x; array) assert (false, "there should be no elements in the array"); array.append(5); assert (array.size == 1); assert (array.capacity >= 1); - assert (array.data); + assert (array.data !is null); foreach (x; array) assert (x == 5); array.append(6); assert (array.size == 2); assert (array.capacity >= 2); - assert (array.data); + assert (array.data !is null); int i = 0; foreach (x; array) assert (x == 5 + i++); @@ -173,19 +173,19 @@ private: array.remove(5); assert (array.size == 1); assert (array.capacity >= 1); - assert (array.data); + assert (array.data !is null); foreach (x; array) assert (x == 6); array.expand(100); assert (array.size == 1); assert (array.capacity >= 100); - assert (array.data); + assert (array.data !is null); foreach (x; array) assert (x == 6); array.clear(); assert (array.size == 0); assert (array.capacity == 0); - assert (array.data == null); + assert (array.data is null); foreach (x; array) assert (false, "there should be no elements in the array"); }