gvalue: Add g_value_clear method

This method is similar to g_value_unset() but will accept
an uninitialized (zero-filled) GValue structure.

https://bugzilla.gnome.org/show_bug.cgi?id=755766
This commit is contained in:
Nicolas Dufresne
2015-09-28 19:41:28 -04:00
committed by Nicolas Dufresne
parent b36b4941a6
commit 1233962b54
3 changed files with 23 additions and 0 deletions

View File

@@ -273,6 +273,26 @@ g_value_unset (GValue *value)
memset (value, 0, sizeof (*value));
}
/**
* g_value_clear:
* @value: An #GValue structure.
*
* Clears the current value in @value and "unsets" the type,
* this releases all resources associated with this GValue.
* Unlike g_value_unset() this method will accept uninitialized
* (zero-filled) #GValue structure as @value.
*
* Since 2.48
*/
void
g_value_clear (GValue *value)
{
if (value && value->g_type == 0)
return;
g_value_unset (value);
}
/**
* g_value_fits_pointer:
* @value: An initialized #GValue structure.