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



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