Re: Is this OK?



On Mon, 2002-10-14 at 10:19, ginxd btopenworld com wrote:
I tend to use g_new also.  At the end of the day, you could use g_malloc, but if that was there anyway why 
create g_new? The way I see it, g_new is there as a definition to what ever function glib decides to call, 
eg: if that is changed in the future (unlikely) g_new would be modified to point to the new g_malloc 
function (if that ever happened).

Regards,

Martyn

 from:    Harring Figueiredo <harringf yahoo com>
 date:    Mon, 14 Oct 2002 00:40:11
 to:      sb125499 ohiou edu, gtk-app-devel-list gnome org
 subject: Re: Is this OK?


  My 2 cents.

  g_malloc0 and g_new0 are EXACTLY the same, with one little difference.
  With g_new0 one does not have to cast to the appropriate type.


 From gmem.c 

62 #define g_new0(struct_type, n_structs)          \
63     ((struct_type *) g_malloc0 (((gsize) sizeof (struct_type)) * ((gsize  )
(n_structs))))


  Hope this clarifies.

Harring.



--- Scott Barron <sb125499 ohiou edu> wrote:
On Sun, Oct 13, 2002 at 06:39:36PM -0400, Scott Barron wrote:
KStudent*
k_student_new ()
{
        KStudent *student = g_new0(KStudent, 1); 
        student->profile = g_new0(KEducationProfile, 1);
        student->father = g_new0(KParent, 1); 
        student->mother = g_new0(KParent, 1);
        student->foster = g_new0(KParent, 1);
        return student;
}

Woops, g_malloc0() is probably better than g_new0() in the case of
always just allocating one structure.  Sorry :)

-Scott
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

THANKS Developers for __ALL__ Your help!!!





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]