summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2024-04-20 19:03:35 +0200
committerBenBE <BenBE@geshi.org>2024-04-20 19:36:00 +0200
commit6f142695cbf5281dd2a5f67b7233d6b93111fa99 (patch)
treea389a9b3b8c1398ceafc3b236bb6bfabb67b356b
parent784ef0878a22e068c87a722059b0e813b1bc1dfe (diff)
Use struct member to determine size of allocations
-rw-r--r--Header.c4
-rw-r--r--Settings.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/Header.c b/Header.c
index 42f6d204..8a9eae34 100644
--- a/Header.c
+++ b/Header.c
@@ -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++) {
diff --git a/Settings.c b/Settings.c
index 9b457d86..07b7e6a2 100644
--- a/Settings.c
+++ b/Settings.c
@@ -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];
}

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