Re: g_object_new(G_TYPE_OBJECT,NULL) failed
- From: Tristan Van Berkom <tvb gnome org>
- To: Yueyu Lin <popeyelin 163 com>
- Cc: gtklist <gtk-list gnome org>
- Subject: Re: g_object_new(G_TYPE_OBJECT,NULL) failed
- Date: Wed, 23 Mar 2005 14:20:31 -0500
Yueyu Lin wrote:
[...]
> I have another question: why GInstanceInitFunc is needed
> since the constructor can do the same thing? Is it possible to not
> override the parent's constructor just add new codes in the
GInstanceInitFunc?
Yes;
Usualy (or I guess I should say "historicly") people use the
GInstanceInitFunc in the GTypeInfo struct to initialize new instances
and omit assigning a constructor method to the GObjectClass at all;
If I'm not mistaken, people can use the "constructor" to have an entry
point in the instantiation where all construct properties are already
assigned.
> About the g_newa and g_new0, from the source I think g_newa just call
> system malloc while g_new0 call g_malloc0 that will ensure safe
> pointor operation using one pointor table. Am I right?
See:
http://developer.gnome.org/doc/API/2.0/glib/glib-Memory-Allocation.html#id3061089
And:
http://developer.gnome.org/doc/API/2.0/glib/glib-Memory-Allocation.html#g-alloca
They basicly wrap alloca; which is used to dynamicly allocate *stack*
space; memory allocated with g_newa() should only be used in the current
stack frame and should never be explicitly freed.
Cheers,
-Tristan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]