mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-21 08:28:53 +02:00
Add g_try_new, g_try_new0, g_try_renew and g_try_malloc0. (#169611, Stefan
2005-03-21 Matthias Clasen <mclasen@redhat.com> * glib/gmem.h: Add g_try_new, g_try_new0, g_try_renew and g_try_malloc0. (#169611, Stefan Kost) * glib/gmem.c: Implement g_try_malloc0.
This commit is contained in:
committed by
Matthias Clasen
parent
103fe49b8e
commit
213e90aa18
@@ -1,7 +1,9 @@
|
|||||||
2005-03-21 Matthias Clasen <mclasen@redhat.com>
|
2005-03-21 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* glib/gmem.h: Add g_try_new, g_try_new0 and
|
* glib/gmem.h: Add g_try_new, g_try_new0, g_try_renew and
|
||||||
g_try_renew. (#169611, Stefan Kost)
|
g_try_malloc0. (#169611, Stefan Kost)
|
||||||
|
|
||||||
|
* glib/gmem.c: Implement g_try_malloc0.
|
||||||
|
|
||||||
2005-03-20 Tor Lillqvist <tml@novell.com>
|
2005-03-20 Tor Lillqvist <tml@novell.com>
|
||||||
|
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
2005-03-21 Matthias Clasen <mclasen@redhat.com>
|
2005-03-21 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* glib/gmem.h: Add g_try_new, g_try_new0 and
|
* glib/gmem.h: Add g_try_new, g_try_new0, g_try_renew and
|
||||||
g_try_renew. (#169611, Stefan Kost)
|
g_try_malloc0. (#169611, Stefan Kost)
|
||||||
|
|
||||||
|
* glib/gmem.c: Implement g_try_malloc0.
|
||||||
|
|
||||||
2005-03-20 Tor Lillqvist <tml@novell.com>
|
2005-03-20 Tor Lillqvist <tml@novell.com>
|
||||||
|
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
2005-03-21 Matthias Clasen <mclasen@redhat.com>
|
2005-03-21 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* glib/gmem.h: Add g_try_new, g_try_new0 and
|
* glib/gmem.h: Add g_try_new, g_try_new0, g_try_renew and
|
||||||
g_try_renew. (#169611, Stefan Kost)
|
g_try_malloc0. (#169611, Stefan Kost)
|
||||||
|
|
||||||
|
* glib/gmem.c: Implement g_try_malloc0.
|
||||||
|
|
||||||
2005-03-20 Tor Lillqvist <tml@novell.com>
|
2005-03-20 Tor Lillqvist <tml@novell.com>
|
||||||
|
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
2005-03-21 Matthias Clasen <mclasen@redhat.com>
|
2005-03-21 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* glib/gmem.h: Add g_try_new, g_try_new0 and
|
* glib/gmem.h: Add g_try_new, g_try_new0, g_try_renew and
|
||||||
g_try_renew. (#169611, Stefan Kost)
|
g_try_malloc0. (#169611, Stefan Kost)
|
||||||
|
|
||||||
|
* glib/gmem.c: Implement g_try_malloc0.
|
||||||
|
|
||||||
2005-03-20 Tor Lillqvist <tml@novell.com>
|
2005-03-20 Tor Lillqvist <tml@novell.com>
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
* glib/glib-sections.txt:
|
* glib/glib-sections.txt:
|
||||||
* glib/tmpl/memory.sgml: Document g_try_new, g_try_new0
|
* glib/tmpl/memory.sgml: Document g_try_new, g_try_new0
|
||||||
and g_try_renew.
|
and g_try_renew, g_try_malloc0.
|
||||||
|
|
||||||
2005-03-20 Matthias Clasen <mclasen@redhat.com>
|
2005-03-20 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
@@ -772,6 +772,7 @@ g_malloc
|
|||||||
g_malloc0
|
g_malloc0
|
||||||
g_realloc
|
g_realloc
|
||||||
g_try_malloc
|
g_try_malloc
|
||||||
|
g_try_malloc0
|
||||||
g_try_realloc
|
g_try_realloc
|
||||||
|
|
||||||
<SUBSECTION>
|
<SUBSECTION>
|
||||||
|
@@ -144,6 +144,17 @@ Contrast with g_malloc(), which aborts the program on failure.
|
|||||||
@Returns: the allocated memory, or %NULL.
|
@Returns: the allocated memory, or %NULL.
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION g_try_malloc0 ##### -->
|
||||||
|
<para>
|
||||||
|
Attempts to allocate @n_bytes, initialized to 0's, and returns %NULL on
|
||||||
|
failure. Contrast with g_malloc0(), which aborts the program on failure.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@n_bytes: number of bytes to allocate.
|
||||||
|
@Returns: the allocated memory, or %NULL.
|
||||||
|
@Since: 2.8
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### FUNCTION g_try_realloc ##### -->
|
<!-- ##### FUNCTION g_try_realloc ##### -->
|
||||||
<para>
|
<para>
|
||||||
Attempts to realloc @mem to a new size, @n_bytes, and returns %NULL
|
Attempts to realloc @mem to a new size, @n_bytes, and returns %NULL
|
||||||
|
13
glib/gmem.c
13
glib/gmem.c
@@ -196,6 +196,19 @@ g_try_malloc (gulong n_bytes)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpointer
|
||||||
|
g_try_malloc0 (gulong n_bytes)
|
||||||
|
{
|
||||||
|
gpointer mem;
|
||||||
|
|
||||||
|
mem = g_try_malloc (n_bytes);
|
||||||
|
|
||||||
|
if (mem)
|
||||||
|
memset (mem, 0, n_bytes);
|
||||||
|
|
||||||
|
return mem;
|
||||||
|
}
|
||||||
|
|
||||||
gpointer
|
gpointer
|
||||||
g_try_realloc (gpointer mem,
|
g_try_realloc (gpointer mem,
|
||||||
gulong n_bytes)
|
gulong n_bytes)
|
||||||
|
@@ -51,6 +51,7 @@ gpointer g_realloc (gpointer mem,
|
|||||||
gulong n_bytes);
|
gulong n_bytes);
|
||||||
void g_free (gpointer mem);
|
void g_free (gpointer mem);
|
||||||
gpointer g_try_malloc (gulong n_bytes) G_GNUC_MALLOC;
|
gpointer g_try_malloc (gulong n_bytes) G_GNUC_MALLOC;
|
||||||
|
gpointer g_try_malloc0 (gulong n_bytes) G_GNUC_MALLOC;
|
||||||
gpointer g_try_realloc (gpointer mem,
|
gpointer g_try_realloc (gpointer mem,
|
||||||
gulong n_bytes);
|
gulong n_bytes);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user