From 6f142695cbf5281dd2a5f67b7233d6b93111fa99 Mon Sep 17 00:00:00 2001 From: Benny Baumann Date: Sat, 20 Apr 2024 19:03:35 +0200 Subject: [PATCH] Use struct member to determine size of allocations --- Header.c | 4 ++-- Settings.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Header.c b/Header.c index 42f6d204b..8a9eae34d 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 9b457d86a..07b7e6a28 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]; }