Function

GLibmemdup

Declaration

gpointer
g_memdup (
  gconstpointer mem,
  guint byte_size
)

Description

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

Deprecated since:2.68

Use g_memdup2() instead, as it accepts a #gsize argument for byte_size, avoiding the possibility of overflow in a #gsize → #guint conversion.

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: guint

The number of bytes to copy.

Return value

Type: gpointer

A pointer to the newly-allocated copy of the memory, or NULL if mem is NULL.

The data is owned by the called function.
The return value can be NULL.