mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-06-02 12:54:26 +00:00
[common] use variable-relative sizeof where possible
This commit is contained in:
committed by
Geoffrey McRae
parent
982b4e6625
commit
1c5620ba25
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user