Function

GLibmemdup2

Declaration

gpointer
g_memdup2 (
  gconstpointer mem,
  gsize 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.

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 gconstpointer
 

The memory to copy.

byte_size gsize
 

The number of bytes to copy.

Return value

Returns: gpointer
 

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