Merge branch 'document-oom-behavior' into 'main'

mem: Document OOM behavior for allocations

See merge request GNOME/glib!2861
This commit is contained in:
Emmanuele Bassi 2022-08-22 14:01:15 +00:00
commit 0e112b457d

View File

@ -115,6 +115,9 @@ static GMemVTable glib_mem_vtable = {
* Allocates @n_bytes bytes of memory.
* If @n_bytes is 0 it returns %NULL.
*
* If the allocation fails (because the system is out of memory),
* the program is terminated.
*
* Returns: a pointer to the allocated memory
*/
gpointer
@ -145,6 +148,9 @@ g_malloc (gsize n_bytes)
* Allocates @n_bytes bytes of memory, initialized to 0's.
* If @n_bytes is 0 it returns %NULL.
*
* If the allocation fails (because the system is out of memory),
* the program is terminated.
*
* Returns: a pointer to the allocated memory
*/
gpointer
@ -179,6 +185,9 @@ g_malloc0 (gsize n_bytes)
* have zero-length. @n_bytes may be 0, in which case %NULL will be returned
* and @mem will be freed unless it is %NULL.
*
* If the allocation fails (because the system is out of memory),
* the program is terminated.
*
* Returns: the new address of the allocated memory
*/
gpointer
@ -349,6 +358,9 @@ g_try_realloc (gpointer mem,
* This function is similar to g_malloc(), allocating (@n_blocks * @n_block_bytes) bytes,
* but care is taken to detect possible overflow during multiplication.
*
* If the allocation fails (because the system is out of memory),
* the program is terminated.
*
* Since: 2.24
* Returns: a pointer to the allocated memory
*/
@ -373,6 +385,9 @@ g_malloc_n (gsize n_blocks,
* This function is similar to g_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes,
* but care is taken to detect possible overflow during multiplication.
*
* If the allocation fails (because the system is out of memory),
* the program is terminated.
*
* Since: 2.24
* Returns: a pointer to the allocated memory
*/
@ -398,6 +413,9 @@ g_malloc0_n (gsize n_blocks,
* This function is similar to g_realloc(), allocating (@n_blocks * @n_block_bytes) bytes,
* but care is taken to detect possible overflow during multiplication.
*
* If the allocation fails (because the system is out of memory),
* the program is terminated.
*
* Since: 2.24
* Returns: the new address of the allocated memory
*/
@ -556,6 +574,9 @@ g_mem_profile (void)
* alignment value. Additionally, it will detect possible overflow during
* multiplication.
*
* If the allocation fails (because the system is out of memory),
* the program is terminated.
*
* Aligned memory allocations returned by this function can only be
* freed using g_aligned_free().
*