diff options
author | Benny Baumann <BenBE@geshi.org> | 2024-04-20 19:03:35 +0200 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2024-04-20 19:36:00 +0200 |
commit | 6f142695cbf5281dd2a5f67b7233d6b93111fa99 (patch) | |
tree | a389a9b3b8c1398ceafc3b236bb6bfabb67b356b | |
parent | 784ef0878a22e068c87a722059b0e813b1bc1dfe (diff) |
Use struct member to determine size of allocations
-rw-r--r-- | Header.c | 4 | ||||
-rw-r--r-- | Settings.c | 4 |
2 files changed, 4 insertions, 4 deletions
@@ -149,8 +149,8 @@ void Header_writeBackToSettings(const Header* this) { const Vector* vec = this->columns[col]; int len = Vector_size(vec); - colSettings->names = len ? xCalloc(len + 1, sizeof(char*)) : NULL; - colSettings->modes = len ? xCalloc(len, sizeof(MeterModeId)) : NULL; + colSettings->names = len ? xCalloc(len + 1, sizeof(*colSettings->names)) : NULL; + colSettings->modes = len ? xCalloc(len, sizeof(*colSettings->modes)) : NULL; colSettings->len = len; for (int i = 0; i < len; i++) { @@ -163,8 +163,8 @@ static void Settings_defaultMeters(Settings* this, unsigned int initialCpuCount) this->hLayout = HF_TWO_50_50; this->hColumns = xCalloc(HeaderLayout_getColumns(this->hLayout), sizeof(MeterColumnSetting)); for (size_t i = 0; i < 2; i++) { - this->hColumns[i].names = xCalloc(sizes[i] + 1, sizeof(char*)); - this->hColumns[i].modes = xCalloc(sizes[i], sizeof(MeterModeId)); + this->hColumns[i].names = xCalloc(sizes[i] + 1, sizeof(*this->hColumns[0].names)); + this->hColumns[i].modes = xCalloc(sizes[i], sizeof(*this->hColumns[0].modes)); this->hColumns[i].len = sizes[i]; } |