Re: g_try_new and g_try_new0 + error reporting for g_object_set



Hi muppet,

I'll now use:

gpointer g_try_malloc0(gulong n_bytes) {
  gpointer mem;

  if((mem=g_try_malloc(n_bytes))) {
    memset(mem,0,n_bytes);
  }
  return(mem);
}

#define g_try_new(struct_type, n_structs) \
  g_try_malloc(sizeof(struct_type)*n_structs)

#define g_try_new0(struct_type, n_structs) { \
  g_try_malloc0(sizeof(struct_type)*n_structs)


It just looks more consistent in the code, that just suddenly directly using g_try_malloc.

Ciao
  Stefan

muppet wrote:
Stefan Kost said:

As the mail remained uncommented, it has now been posted under
http://bugzilla.gnome.org/show_bug.cgi?id=169611

Stefan Kost wrote:

hi hi,

is there a reason why we dont have g_try_new and g_try_new0.


why is g_try_malloc() not sufficient?

http://developer.gnome.org/doc/API/2.0/glib/glib-Memory-Allocation.html#g-try-malloc

or simply using malloc() (or calloc()) directly?





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