gobject: Document that classes/objects/interfaces are zero-filled

On initialisation, GObject guarantees to zero-fill
class/object/interface structures. Document this so people don’t spend
forever writing:
    my_object->priv->some_member = NULL;
    my_object->priv->some_other_member = NULL;

https://bugzilla.gnome.org/show_bug.cgi?id=729167
This commit is contained in:
Philip Withnall
2014-04-29 08:47:14 +01:00
parent cb3f6f9547
commit 704852ff09
3 changed files with 22 additions and 5 deletions

View File

@@ -882,10 +882,14 @@ typedef void (*GClassFinalizeFunc) (gpointer g_class,
* A callback function used by the type system to initialize a new
* instance of a type. This function initializes all instance members and
* allocates any resources required by it.
*
* Initialization of a derived instance involves calling all its parent
* types instance initializers, so the class member of the instance
* is altered during its initialization to always point to the class that
* belongs to the type the current initializer was introduced for.
*
* The extended members of @instance are guaranteed to have been filled with
* zeros before this function is called.
*/
typedef void (*GInstanceInitFunc) (GTypeInstance *instance,
gpointer g_class);
@@ -897,6 +901,9 @@ typedef void (*GInstanceInitFunc) (GTypeInstance *instance,
* A callback function used by the type system to initialize a new
* interface. This function should initialize all internal data and
* allocate any resources required by the interface.
*
* The members of @iface_data are guaranteed to have been filled with
* zeros before this function is called.
*/
typedef void (*GInterfaceInitFunc) (gpointer g_iface,
gpointer iface_data);