alloc


Description:

public void* alloc (size_t n_blocks, size_t n_blocks_bytes, size_t alignment)

This function is similar to malloc, allocating (n_blocks * n_block_bytes) bytes, but care is taken to align the allocated memory to with the given 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 free_sized or free.

Parameters:

n_blocks

the number of blocks to allocate

alignment

the alignment to be enforced, which must be a positive power of 2 and a multiple of `sizeof(void*)`

n_block_bytes

the size of each block in bytes

Returns:

the allocated memory


Namespace: GLib.Aligned
Package: glib-2.0