X-Git-Url: https://git.llucax.com/software/dgc/cdgc.git/blobdiff_plain/e22e481ad2881b43acdc16fd6061bee9d68270f7..ed2b4ee35ae9c3c6fb0f9c0a808c2945a843701a:/rt/gc/cdgc/dynarray.d?ds=sidebyside diff --git a/rt/gc/cdgc/dynarray.d b/rt/gc/cdgc/dynarray.d index 2a36d93..feddd98 100644 --- a/rt/gc/cdgc/dynarray.d +++ b/rt/gc/cdgc/dynarray.d @@ -79,6 +79,14 @@ public: return this._capacity; } + /** + * Get the total ammount of bytes the array consumes. + */ + size_t size_of() + { + return this.sizeof + this._capacity * (T.sizeof + (T*).sizeof); + } + /** * Get the pointer to the array's data. * @@ -190,7 +198,7 @@ public: if (new_capacity == 0) new_capacity = this._size * 2; if (new_capacity == 0) - new_capacity = 4; + new_capacity = 16; // reallocate the memory with the new_capacity T* new_data = cast(T*) realloc(this._data, new_capacity * T.sizeof); if (new_data is null)