[common] use variable-relative sizeof where possible

This commit is contained in:
Tudor Brindus authored and Geoffrey McRae committed 2021-08-16 16:22:55 +10:00
1 parent 982b4e6625
commit 1c5620ba25
11 files changed
+21 -23

No files matched your search

+3 -3
View File
@@ -32,7 +32,7 @@ struct StringList
StringList stringlist_new(bool owns_strings)
{
StringList sl = malloc(sizeof(struct StringList));
StringList sl = malloc(sizeof(*sl));
sl->owns_strings = owns_strings;
sl->size = 32;
@@ -58,7 +58,7 @@ int stringlist_push (StringList sl, char * str)
if (sl->count == sl->size)
{
sl->size += 32;
sl->list = realloc(sl->list, sizeof(char *) * sl->size);
sl->list = realloc(sl->list, sizeof(*sl->list) * sl->size);
}
unsigned int index = sl->count;
@@ -77,4 +77,4 @@ char * stringlist_at(StringList sl, unsigned int index)
return NULL;
return sl->list[index];
}
}