GLib.memdup2 (original) (raw)
Function
GLibmemdup2
since: 2.68
Declaration [src]
gpointer
g_memdup2 (
gconstpointer mem,
gsize byte_size
)
Description [src]
Allocates byte_size
bytes of memory, and copies byte_size
bytes into it from mem
. If mem
is NULL
it returns NULL
.
This replaces g_memdup(), which was prone to integer overflows when converting the argument from a gsize
to a guint
.
Available since: 2.68
Parameters
mem
Type: gconstpointer
The memory to copy.
The argument can be NULL. |
---|
The data is owned by the caller of the function. |
byte_size
Type: gsize
The number of bytes to copy.
Return value
Type: gpointer
A pointer to the newly-allocated copy of the memory.
The caller of the function takes ownership of the data, and is responsible for freeing it. |
---|
The return value can be NULL. |