Memory

Members

Static functions

clearPointer
void clearPointer(void** pp, GDestroyNotify destroy)

Clears a reference to a variable.

free
void free(void* mem)

Frees the memory pointed to by @mem.

malloc
void* malloc(size_t nBytes)

Allocates @n_bytes bytes of memory. If @n_bytes is 0 it returns %NULL.

malloc0
void* malloc0(size_t nBytes)

Allocates @n_bytes bytes of memory, initialized to 0's. If @n_bytes is 0 it returns %NULL.

malloc0N
void* malloc0N(size_t nBlocks, size_t nBlockBytes)

This function is similar to g_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes, but care is taken to detect possible overflow during multiplication.

mallocN
void* mallocN(size_t nBlocks, size_t nBlockBytes)

This function is similar to g_malloc(), allocating (@n_blocks * @n_block_bytes) bytes, but care is taken to detect possible overflow during multiplication.

memIsSystemMalloc
bool memIsSystemMalloc()

Checks whether the allocator used by g_malloc() is the system's malloc implementation. If it returns %TRUE memory allocated with malloc() can be used interchangeably with memory allocated using g_malloc(). This function is useful for avoiding an extra copy of allocated memory returned by a non-GLib-based API.

memProfile
void memProfile()

GLib used to support some tools for memory profiling, but this no longer works. There are many other useful tools for memory profiling these days which can be used instead.

memSetVtable
void memSetVtable(GMemVTable* vtable)

This function used to let you override the memory allocation function. However, its use was incompatible with the use of global constructors in GLib and GIO, because those use the GLib allocators before main is reached. Therefore this function is now deprecated and is just a stub.

memdup
void* memdup(void* mem, uint byteSize)

Allocates @byte_size bytes of memory, and copies @byte_size bytes into it from @mem. If @mem is %NULL it returns %NULL.

realloc
void* realloc(void* mem, size_t nBytes)

Reallocates the memory pointed to by @mem, so that it now has space for @n_bytes bytes of memory. It returns the new address of the memory, which may have been moved. @mem may be %NULL, in which case it's considered to have zero-length. @n_bytes may be 0, in which case %NULL will be returned and @mem will be freed unless it is %NULL.

reallocN
void* reallocN(void* mem, size_t nBlocks, size_t nBlockBytes)

This function is similar to g_realloc(), allocating (@n_blocks * @n_block_bytes) bytes, but care is taken to detect possible overflow during multiplication.

tryMalloc
void* tryMalloc(size_t nBytes)

Attempts to allocate @n_bytes, and returns %NULL on failure. Contrast with g_malloc(), which aborts the program on failure.

tryMalloc0
void* tryMalloc0(size_t nBytes)

Attempts to allocate @n_bytes, initialized to 0's, and returns %NULL on failure. Contrast with g_malloc0(), which aborts the program on failure.

tryMalloc0N
void* tryMalloc0N(size_t nBlocks, size_t nBlockBytes)

This function is similar to g_try_malloc0(), allocating (@n_blocks * @n_block_bytes) bytes, but care is taken to detect possible overflow during multiplication.

tryMallocN
void* tryMallocN(size_t nBlocks, size_t nBlockBytes)

This function is similar to g_try_malloc(), allocating (@n_blocks * @n_block_bytes) bytes, but care is taken to detect possible overflow during multiplication.

tryRealloc
void* tryRealloc(void* mem, size_t nBytes)

Attempts to realloc @mem to a new size, @n_bytes, and returns %NULL on failure. Contrast with g_realloc(), which aborts the program on failure.

tryReallocN
void* tryReallocN(void* mem, size_t nBlocks, size_t nBlockBytes)

This function is similar to g_try_realloc(), allocating (@n_blocks * @n_block_bytes) bytes, but care is taken to detect possible overflow during multiplication.

Meta