summaryrefslogtreecommitdiffstats
path: root/Vector.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2024-04-02 19:30:44 +0200
committercgzones <cgzones@googlemail.com>2024-04-05 19:25:20 +0200
commit869220b5896e9bf5e9072254ab99779c960e3eae (patch)
treefdf5dc9f6589e40a90bb94d7552fac67789834fd /Vector.c
parent5846b7df4e891e3db85e2719d5d28507e0da2468 (diff)
Use designated initializer more
Designated initializers are supported in C99 and simplify struct initializations. All members not explicitly mentioned are default initialized to 0, and also modern compilers can warn on of those missing ones.
Diffstat (limited to 'Vector.c')
-rw-r--r--Vector.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/Vector.c b/Vector.c
index 0e08c650..aeb19391 100644
--- a/Vector.c
+++ b/Vector.c
@@ -25,14 +25,16 @@ Vector* Vector_new(const ObjectClass* type, bool owner, int size) {
assert(size > 0);
this = xMalloc(sizeof(Vector));
- this->growthRate = size;
- this->array = (Object**) xCalloc(size, sizeof(Object*));
- this->arraySize = size;
- this->items = 0;
- this->type = type;
- this->owner = owner;
- this->dirty_index = -1;
- this->dirty_count = 0;
+ *this = (Vector) {
+ .growthRate = size,
+ .array = xCalloc(size, sizeof(Object*)),
+ .arraySize = size,
+ .items = 0,
+ .type = type,
+ .owner = owner,
+ .dirty_index = -1,
+ .dirty_count = 0,
+ };
return this;
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy