summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Hashtable.c16
-rw-r--r--Vector.c18
2 files changed, 19 insertions, 15 deletions
diff --git a/Hashtable.c b/Hashtable.c
index 2756b232..041f25eb 100644
--- a/Hashtable.c
+++ b/Hashtable.c
@@ -109,13 +109,15 @@ static size_t nextPrime(size_t n) {
}
Hashtable* Hashtable_new(size_t size, bool owner) {
- Hashtable* this;
-
- this = xMalloc(sizeof(Hashtable));
- this->items = 0;
- this->size = size ? nextPrime(size) : 13;
- this->buckets = (HashtableItem*) xCalloc(this->size, sizeof(HashtableItem));
- this->owner = owner;
+ size = size ? nextPrime(size) : 13;
+
+ Hashtable* this = xMalloc(sizeof(Hashtable));
+ *this = (Hashtable) {
+ .items = 0,
+ .size = size,
+ .buckets = xCalloc(size, sizeof(HashtableItem)),
+ .owner = owner,
+ };
assert(Hashtable_isConsistent(this));
return this;
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;
}