mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-05 10:38:08 +01:00
Fix size of preallocated array
Commit 084e1d868 added a preallocation to an array to avoid reallocations later on, but neglected the fact that after N insertions into the array, there’s always a NULL terminator added to the end. Fix the preallocation to include that NULL terminator. This doesn’t change the correctness of the code, but should eliminate one reallocation. Spotted by Sebastian Dröge. See https://gitlab.gnome.org/GNOME/glib/merge_requests/674. Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
parent
1fb31a16c3
commit
7bf49c8df7
@ -462,7 +462,7 @@ gvdb_table_get_names (GvdbTable *table,
|
|||||||
{
|
{
|
||||||
GPtrArray *fixed_names;
|
GPtrArray *fixed_names;
|
||||||
|
|
||||||
fixed_names = g_ptr_array_sized_new (n_names);
|
fixed_names = g_ptr_array_sized_new (n_names + 1 /* NULL terminator */);
|
||||||
for (i = 0; i < n_names; i++)
|
for (i = 0; i < n_names; i++)
|
||||||
if (names[i] != NULL)
|
if (names[i] != NULL)
|
||||||
g_ptr_array_add (fixed_names, names[i]);
|
g_ptr_array_add (fixed_names, names[i]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user