Skip to content

Commit 6f14269

Browse files
committed
Use struct member to determine size of allocations
1 parent 784ef08 commit 6f14269

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Header.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ void Header_writeBackToSettings(const Header* this) {
149149
const Vector* vec = this->columns[col];
150150
int len = Vector_size(vec);
151151

152-
colSettings->names = len ? xCalloc(len + 1, sizeof(char*)) : NULL;
153-
colSettings->modes = len ? xCalloc(len, sizeof(MeterModeId)) : NULL;
152+
colSettings->names = len ? xCalloc(len + 1, sizeof(*colSettings->names)) : NULL;
153+
colSettings->modes = len ? xCalloc(len, sizeof(*colSettings->modes)) : NULL;
154154
colSettings->len = len;
155155

156156
for (int i = 0; i < len; i++) {

Settings.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ static void Settings_defaultMeters(Settings* this, unsigned int initialCpuCount)
163163
this->hLayout = HF_TWO_50_50;
164164
this->hColumns = xCalloc(HeaderLayout_getColumns(this->hLayout), sizeof(MeterColumnSetting));
165165
for (size_t i = 0; i < 2; i++) {
166-
this->hColumns[i].names = xCalloc(sizes[i] + 1, sizeof(char*));
167-
this->hColumns[i].modes = xCalloc(sizes[i], sizeof(MeterModeId));
166+
this->hColumns[i].names = xCalloc(sizes[i] + 1, sizeof(*this->hColumns[0].names));
167+
this->hColumns[i].modes = xCalloc(sizes[i], sizeof(*this->hColumns[0].modes));
168168
this->hColumns[i].len = sizes[i];
169169
}
170170

0 commit comments

Comments
 (0)