mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-07-30 13:53:30 +02:00
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:
@@ -147,7 +147,9 @@ GType maman_bar_get_type (void);
|
||||
macro with the G_DEFINE_TYPE_WITH_CODE() or the G_DEFINE_TYPE_EXTENDED()
|
||||
macros. The private structure is then defined in the .c file,
|
||||
and can be accessed using the <function>get_instance_private()</function>
|
||||
function generated by the G_DEFINE_TYPE_* macros.
|
||||
function generated by the G_DEFINE_TYPE_* macros. It is automatically
|
||||
zero-filled on creation, so it is unnecessary to explicitly
|
||||
initialize pointer members to NULL.
|
||||
<programlisting>
|
||||
struct _MamanBarPrivate
|
||||
{
|
||||
@@ -333,7 +335,8 @@ maman_bar_init (MamanBar *self)
|
||||
{
|
||||
self->priv = maman_bar_get_instance_private (self);
|
||||
|
||||
/* initialize all public and private members to reasonable default values. */
|
||||
/* initialize all public and private members to reasonable default values.
|
||||
* They are all automatically initialized to 0 to begin with. */
|
||||
}
|
||||
</programlisting>
|
||||
</para>
|
||||
@@ -574,7 +577,7 @@ maman_bar_do_action (MamanBar *self, /* parameters */)
|
||||
implementation for this class method in the object's
|
||||
<function>class_init</function> function: initialize the
|
||||
klass->do_action field to a pointer to the actual implementation.
|
||||
By default, class method that are not inherited are initialized to
|
||||
By default, class methods that are not inherited are initialized to
|
||||
NULL, and thus are to be considered "pure virtual".
|
||||
<programlisting>
|
||||
static void
|
||||
|
Reference in New Issue
Block a user