Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/eglib
diff options
context:
space:
mode:
authorBill Holmes <holmes@mono-cvs.ximian.com>2008-08-04 17:49:56 +0400
committerBill Holmes <holmes@mono-cvs.ximian.com>2008-08-04 17:49:56 +0400
commitfab9dfdc5a74007b0ae7b3881f2760b4f2e11849 (patch)
treea3a3b0a3e338925f75db8c1b82033c5bf3cabcfc /eglib
parent633e47364f492eea3c58533b5d7c953778951e77 (diff)
2008-08-04 Bill Holmes <billholmes54@gmail.com>
* src/glib.h : Changing the allocation routines to return null if 0 size is passed in. Contributed under MIT/X11 license. svn path=/trunk/mono/; revision=109563
Diffstat (limited to 'eglib')
-rw-r--r--eglib/ChangeLog8
-rw-r--r--eglib/src/glib.h21
2 files changed, 20 insertions, 9 deletions
diff --git a/eglib/ChangeLog b/eglib/ChangeLog
index cf49ada0a45..66a1c56b38f 100644
--- a/eglib/ChangeLog
+++ b/eglib/ChangeLog
@@ -1,3 +1,10 @@
+2008-08-04 Bill Holmes <billholmes54@gmail.com>
+
+ * src/glib.h : Changing the allocation routines to return null if 0 size is
+ passed in.
+
+ Contributed under MIT/X11 license.
+
2008-06-16 Zoltan Varga <vargaz@gmail.com>
* src/vasprintf.c (vasprintf): Applied patch from Michail Ushakov
@@ -1133,3 +1140,4 @@ Mon Oct 9 12:59:16 CEST 2006 Paolo Molaro <lupus@ximian.com>
untested at this point.
+
diff --git a/eglib/src/glib.h b/eglib/src/glib.h
index 77791d31283..b63ede01fa1 100644
--- a/eglib/src/glib.h
+++ b/eglib/src/glib.h
@@ -101,18 +101,20 @@ typedef uint16_t gunichar2;
/*
* Allocation
*/
-#define g_new(type,size) ((type *) malloc (sizeof (type) * (size)))
-#define g_new0(type,size) ((type *) calloc (sizeof (type), (size)))
+#define g_free free
+static inline gpointer g_realloc (gpointer obj, gsize size) { if (!size) {g_free (obj); return 0;} return realloc (obj, size);}
+static inline gpointer g_malloc (gsize x) {if (x) return malloc (x); else return 0;}
+static inline gpointer g_malloc0 (gsize x) {if (x) return calloc(1,x); else return 0;}
+#define g_try_malloc(x) g_malloc(x)
+#define g_try_realloc(obj,size) g_realloc((obj),(size))
+
+#define g_new(type,size) ((type *) g_malloc (sizeof (type) * (size)))
+#define g_new0(type,size) ((type *) g_malloc0 (sizeof (type)* (size)))
#define g_newa(type,size) ((type *) alloca (sizeof (type) * (size)))
-#define g_realloc(obj,size) realloc((obj), (size))
-#define g_malloc(x) malloc(x)
-#define g_try_malloc(x) malloc(x)
-#define g_try_realloc(obj,size) realloc((obj),(size))
-#define g_malloc0(x) calloc(1,x)
+
#define g_memmove(dest,src,len) memmove (dest, src, len)
-#define g_renew(struct_type, mem, n_structs) realloc (mem, sizeof (struct_type) * n_structs)
+#define g_renew(struct_type, mem, n_structs) g_realloc (mem, sizeof (struct_type) * n_structs)
#define g_alloca(size) alloca (size)
-#define g_free free
gpointer g_memdup (gconstpointer mem, guint byte_size);
gchar *g_strdup (const gchar *str);
@@ -822,3 +824,4 @@ gboolean g_utf8_validate (const gchar *str, gssize max_len, const gchar **
#endif
+