aboutsummaryrefslogtreecommitdiff
path: root/src/array.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/array.cpp')
-rw-r--r--src/array.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/array.cpp b/src/array.cpp
index 6809574df..c28463c1b 100644
--- a/src/array.cpp
+++ b/src/array.cpp
@@ -54,7 +54,10 @@ gb_inline void array_init(Array<T> *array, gbAllocator const &a, isize count) {
template <typename T>
gb_inline void array_init(Array<T> *array, gbAllocator const &a, isize count, isize capacity) {
array->allocator = a;
- array->data = gb_alloc_array(a, T, capacity);
+ array->data = nullptr;
+ if (capacity > 0) {
+ array->data = gb_alloc_array(a, T, capacity);
+ }
array->count = count;
array->capacity = capacity;
}