[glib] Clarification for memmory allocation function



commit 382d13b6181b66bd9b842c30742c444f30004c79
Author: Pavlo Solntsev <pavlo solntsev gmail com>
Date:   Thu Jan 25 10:41:30 2018 -0600

    Clarification for memmory allocation function
    
    Difference between g_try_... family of functions and their counterparts
    has been clarified.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=792903

 glib/gmem.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/glib/gmem.c b/glib/gmem.c
index 0140d4b..c4f42c5 100644
--- a/glib/gmem.c
+++ b/glib/gmem.c
@@ -63,9 +63,14 @@ static GMemVTable glib_mem_vtable = {
  * 
  * These functions provide support for allocating and freeing memory.
  * 
- * If any call to allocate memory fails, the application is terminated.
- * This also means that there is no need to check if the call succeeded.
- * 
+ * If any call to allocate memory using functions g_new(), g_new0(), g_renew(),
+ * g_malloc(), g_malloc0(), g_malloc0_n(), g_realloc(), and g_realloc_n()
+ * fails, the application is terminated. This also means that there is no
+ * need to check if the call succeeded. On the other hand, g_try_...() family
+ * of functions returns %NULL on failure that can be used as a check
+ * for unsuccessful memory allocation. The application is not terminated
+ * in this case.
+ *
  * It's important to match g_malloc() (and wrappers such as g_new()) with
  * g_free(), g_slice_alloc() (and wrappers such as g_slice_new()) with
  * g_slice_free(), plain malloc() with free(), and (if you're using C++)


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