Github User Fetcher 1.0.0
C Application with Server and GUI
|
Go to the source code of this file.
Data Structures | |
struct | _GMemVTable |
Macros | |
#define | G_MEM_ALIGN GLIB_SIZEOF_LONG |
#define | g_clear_pointer(pp, destroy) |
#define | g_steal_pointer(pp) (0 ? (*(pp)) : (g_steal_pointer) (pp)) |
#define | _G_NEW(struct_type, n_structs, func) ((struct_type *) g_##func##_n ((n_structs), sizeof (struct_type))) |
#define | _G_RENEW(struct_type, mem, n_structs, func) ((struct_type *) g_##func##_n (mem, (n_structs), sizeof (struct_type))) |
#define | g_new(struct_type, n_structs) _G_NEW (struct_type, n_structs, malloc) |
#define | g_new0(struct_type, n_structs) _G_NEW (struct_type, n_structs, malloc0) |
#define | g_renew(struct_type, mem, n_structs) _G_RENEW (struct_type, mem, n_structs, realloc) |
#define | g_try_new(struct_type, n_structs) _G_NEW (struct_type, n_structs, try_malloc) |
#define | g_try_new0(struct_type, n_structs) _G_NEW (struct_type, n_structs, try_malloc0) |
#define | g_try_renew(struct_type, mem, n_structs) _G_RENEW (struct_type, mem, n_structs, try_realloc) |
Typedefs | |
typedef typedefG_BEGIN_DECLS struct _GMemVTable | GMemVTable |
Variables | |
GLIB_VAR gboolean | g_mem_gc_friendly |
GLIB_VAR GMemVTable * | glib_mem_profiler_table |
#define _G_NEW | ( | struct_type, | |
n_structs, | |||
func ) ((struct_type *) g_##func##_n ((n_structs), sizeof (struct_type))) |
#define _G_RENEW | ( | struct_type, | |
mem, | |||
n_structs, | |||
func ) ((struct_type *) g_##func##_n (mem, (n_structs), sizeof (struct_type))) |
#define g_clear_pointer | ( | pp, | |
destroy ) |
Definition at line 148 of file gmem.h.
#define G_MEM_ALIGN GLIB_SIZEOF_LONG |
g_new: @struct_type: the type of the elements to allocate @n_structs: the number of elements to allocate
Allocates @n_structs elements of type @struct_type. The returned pointer is cast to a pointer to the given type. If @n_structs is 0 it returns NULL. Care is taken to avoid overflow when calculating the size of the allocated block.
Since the returned pointer is already casted to the right type, it is normally unnecessary to cast it explicitly, and doing so might hide memory allocation errors.
Returns: a pointer to the allocated memory, cast to a pointer to @struct_type
Definition at line 315 of file gmem.h.
Referenced by g_object_notify_queue_thaw().
#define g_new0 | ( | struct_type, | |
n_structs ) _G_NEW (struct_type, n_structs, malloc0) |
g_new0: @struct_type: the type of the elements to allocate. @n_structs: the number of elements to allocate.
Allocates @n_structs elements of type @struct_type, initialized to 0's. The returned pointer is cast to a pointer to the given type. If @n_structs is 0 it returns NULL. Care is taken to avoid overflow when calculating the size of the allocated block.
Since the returned pointer is already casted to the right type, it is normally unnecessary to cast it explicitly, and doing so might hide memory allocation errors.
Returns: a pointer to the allocated memory, cast to a pointer to @struct_type.
Definition at line 332 of file gmem.h.
Referenced by activate().
g_renew: @struct_type: the type of the elements to allocate @mem: the currently allocated memory @n_structs: the number of elements to allocate
Reallocates the memory pointed to by @mem, so that it now has space for @n_structs elements of type @struct_type. It returns the new address of the memory, which may have been moved. Care is taken to avoid overflow when calculating the size of the allocated block.
Returns: a pointer to the new allocated memory, cast to a pointer to @struct_type
#define g_steal_pointer | ( | pp | ) | (0 ? (*(pp)) : (g_steal_pointer) (pp)) |
#define g_try_new | ( | struct_type, | |
n_structs ) _G_NEW (struct_type, n_structs, try_malloc) |
g_try_new: @struct_type: the type of the elements to allocate @n_structs: the number of elements to allocate
Attempts to allocate @n_structs elements of type @struct_type, and returns NULL on failure. Contrast with g_new(), which aborts the program on failure. The returned pointer is cast to a pointer to the given type. The function returns NULL when @n_structs is 0 of if an overflow occurs.
Since: 2.8 Returns: a pointer to the allocated memory, cast to a pointer to @struct_type
#define g_try_new0 | ( | struct_type, | |
n_structs ) _G_NEW (struct_type, n_structs, try_malloc0) |
g_try_new0: @struct_type: the type of the elements to allocate @n_structs: the number of elements to allocate
Attempts to allocate @n_structs elements of type @struct_type, initialized to 0's, and returns NULL on failure. Contrast with g_new0(), which aborts the program on failure. The returned pointer is cast to a pointer to the given type. The function returns NULL when @n_structs is 0 or if an overflow occurs.
Since: 2.8 Returns: a pointer to the allocated memory, cast to a pointer to @struct_type
#define g_try_renew | ( | struct_type, | |
mem, | |||
n_structs ) _G_RENEW (struct_type, mem, n_structs, try_realloc) |
g_try_renew: @struct_type: the type of the elements to allocate @mem: the currently allocated memory @n_structs: the number of elements to allocate
Attempts to reallocate the memory pointed to by @mem, so that it now has space for @n_structs elements of type @struct_type, and returns NULL on failure. Contrast with g_renew(), which aborts the program on failure. It returns the new address of the memory, which may have been moved. The function returns NULL if an overflow occurs.
Since: 2.8 Returns: a pointer to the new allocated memory, cast to a pointer to @struct_type
typedef typedefG_BEGIN_DECLS struct _GMemVTable GMemVTable |
GMemVTable: @malloc: function to use for allocating memory. @realloc: function to use for reallocating memory. @free: function to use to free memory. @calloc: function to use for allocating zero-filled memory. @try_malloc: function to use for allocating memory without a default error handler. @try_realloc: function to use for reallocating memory without a default error handler.
A set of functions used to perform memory allocation. The same GMemVTable must be used for all allocations in the same program; a call to g_mem_set_vtable(), if it exists, should be prior to any use of GLib.
This functions related to this has been deprecated in 2.46, and no longer work.
GLIB_AVAILABLE_IN_2_72 gpointer g_aligned_alloc | ( | gsize | n_blocks, |
gsize | n_block_bytes, | ||
gsize | alignment ) |
GLIB_AVAILABLE_IN_2_72 gpointer GLIB_AVAILABLE_IN_2_72 gpointer g_aligned_alloc0 | ( | gsize | n_blocks, |
gsize | n_block_bytes, | ||
gsize | alignment ) |
GLIB_AVAILABLE_IN_2_72 gpointer GLIB_AVAILABLE_IN_2_72 gpointer GLIB_AVAILABLE_IN_2_72 void g_aligned_free | ( | gpointer | mem | ) |
GLIB_AVAILABLE_IN_2_76 void g_aligned_free_sized | ( | gpointer | mem, |
size_t | alignment, | ||
size_t | size ) |
GLIB_AVAILABLE_IN_2_34 void g_clear_pointer | ( | gpointer * | pp, |
GDestroyNotify | destroy ) |
GLIB_AVAILABLE_IN_ALL void g_free | ( | gpointer | mem | ) |
Referenced by g_autoptr_cleanup_generic_gfree(), g_object_notify_queue_thaw(), g_set_str(), and on_button_clicked().
GLIB_AVAILABLE_IN_2_76 void g_free_sized | ( | gpointer | mem, |
size_t | size ) |
GLIB_AVAILABLE_IN_ALL gpointer g_malloc | ( | gsize | n_bytes | ) |
Referenced by g_strjoin().
GLIB_AVAILABLE_IN_ALL gpointer g_malloc0 | ( | gsize | n_bytes | ) |
GLIB_AVAILABLE_IN_ALL gpointer GLIB_AVAILABLE_IN_ALL gpointer g_malloc0_n | ( | gsize | n_blocks, |
gsize | n_block_bytes ) |
GLIB_AVAILABLE_IN_ALL gpointer g_malloc_n | ( | gsize | n_blocks, |
gsize | n_block_bytes ) |
GLIB_DEPRECATED_IN_2_46 gboolean g_mem_is_system_malloc | ( | void | ) |
GLIB_DEPRECATED_IN_2_46 void g_mem_profile | ( | void | ) |
GLIB_DEPRECATED_IN_2_46 void g_mem_set_vtable | ( | GMemVTable * | vtable | ) |
GLIB_AVAILABLE_IN_ALL gpointer g_realloc | ( | gpointer | mem, |
gsize | n_bytes ) |
GLIB_AVAILABLE_IN_ALL gpointer GLIB_AVAILABLE_IN_ALL gpointer GLIB_AVAILABLE_IN_ALL gpointer g_realloc_n | ( | gpointer | mem, |
gsize | n_blocks, | ||
gsize | n_block_bytes ) |
|
inlinestatic |
g_steal_pointer: @pp: (not nullable): a pointer to a pointer
Sets @pp to NULL, returning the value that was there before.
Conceptually, this transfers the ownership of the pointer from the referenced variable to the "caller" of the macro (ie: "steals" the reference).
The return value will be properly typed, according to the type of @pp.
This can be very useful when combined with g_autoptr() to prevent the return value of a function from being automatically freed. Consider the following example (which only works on GCC and clang):
|[ GObject * create_object (void) { g_autoptr(GObject) obj = g_object_new (G_TYPE_OBJECT, NULL);
if (early_error_case) return NULL;
return g_steal_pointer (&obj); } ]|
It can also be used in similar ways for 'out' parameters and is particularly useful for dealing with optional out parameters:
|[ gboolean get_object (GObject **obj_out) { g_autoptr(GObject) obj = g_object_new (G_TYPE_OBJECT, NULL);
if (early_error_case) return FALSE;
if (obj_out) *obj_out = g_steal_pointer (&obj);
return TRUE; } ]|
In the above example, the object will be automatically freed in the early error case and also in the case that NULL was given for @obj_out.
Since: 2.44
Definition at line 234 of file gmem.h.
References NULL.
GLIB_AVAILABLE_IN_ALL gpointer g_try_malloc | ( | gsize | n_bytes | ) |
GLIB_AVAILABLE_IN_ALL gpointer g_try_malloc0 | ( | gsize | n_bytes | ) |
GLIB_AVAILABLE_IN_ALL gpointer GLIB_AVAILABLE_IN_ALL gpointer g_try_malloc0_n | ( | gsize | n_blocks, |
gsize | n_block_bytes ) |
GLIB_AVAILABLE_IN_ALL gpointer g_try_malloc_n | ( | gsize | n_blocks, |
gsize | n_block_bytes ) |
GLIB_AVAILABLE_IN_ALL gpointer g_try_realloc | ( | gpointer | mem, |
gsize | n_bytes ) |
GLIB_AVAILABLE_IN_ALL gpointer GLIB_AVAILABLE_IN_ALL gpointer GLIB_AVAILABLE_IN_ALL gpointer g_try_realloc_n | ( | gpointer | mem, |
gsize | n_blocks, | ||
gsize | n_block_bytes ) |
GLIB_VAR GMemVTable* glib_mem_profiler_table |