[common] use variable-relative sizeof where possible

This commit is contained in:
Tudor Brindus
2021-08-15 12:18:12 -04:00
committed by Geoffrey McRae
parent 982b4e6625
commit 1c5620ba25
11 changed files with 21 additions and 23 deletions

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];
}
}