exported-object: allocate temporary buffer in nm_exported_object_signal_hook() using alloca

The size of GValue is about 24 bytes. The number of arguments
for a signal is also small. No problem allocating the temporary buffer
on the stack.
This commit is contained in:
Thomas Haller
2016-03-30 13:20:44 +02:00
parent 05d4faf334
commit 429cc30607

View File

@@ -171,7 +171,8 @@ nm_exported_object_signal_hook (GSignalInvocationHint *ihint,
}
g_return_val_if_fail (interface != NULL, TRUE);
dbus_param_values = g_new0 (GValue, n_param_values);
dbus_param_values = g_newa (GValue, n_param_values);
memset (dbus_param_values, 0, sizeof (GValue) * n_param_values);
g_value_init (&dbus_param_values[0], G_OBJECT_TYPE (interface));
g_value_set_object (&dbus_param_values[0], interface);
for (i = 1; i < n_param_values; i++) {
@@ -193,7 +194,6 @@ nm_exported_object_signal_hook (GSignalInvocationHint *ihint,
for (i = 0; i < n_param_values; i++)
g_value_unset (&dbus_param_values[i]);
g_free (dbus_param_values);
return TRUE;
}