gdataset: avoid initializing temporary array with NULL in g_data_remove_internal()

The code comment was correct in the past, and how the code was then we
had to ensure the array is initialized.

This is no longer the case. We will only access the array at the indexes
from zero to up to (found_keys-1). And those places get always
initialized before we use them (as we increment found_keys at the same
time).

There is no longer a need to initialize this array to zero. Drop this.

Fixes: 3437414dd4 ('gdataset: use lookup index in g_datalist_id_remove_multiple()')
This commit is contained in:
Thomas Haller
2025-02-21 09:53:44 +01:00
parent e35c796e62
commit 76d77d1cab

View File

@@ -737,17 +737,15 @@ g_data_remove_internal (GData **datalist,
/* Allocate an array of GDataElt to hold copies of the elements
* that are removed from the datalist. Allow enough space for all
* the keys; if a key is not found, the corresponding element of
* old is not populated, so we initialize them all to NULL to
* detect that case.
* the keys.
*
* At most allocate 400 bytes on the stack. Especially since we call
* out to external code, we don't know how much stack we can use. */
if (n_keys <= 400u / sizeof (GDataElt))
old = g_newa0 (GDataElt, n_keys);
old = g_newa (GDataElt, n_keys);
else
{
old_to_free = g_new0 (GDataElt, n_keys);
old_to_free = g_new (GDataElt, n_keys);
old = old_to_free;
}