Commit 0fb81c1d authored by osku's avatar osku

Add mem_heap_dup().

parent 66946183
...@@ -322,6 +322,17 @@ mem_heap_strcat( ...@@ -322,6 +322,17 @@ mem_heap_strcat(
const char* s1, /* in: string 1 */ const char* s1, /* in: string 1 */
const char* s2); /* in: string 2 */ const char* s2); /* in: string 2 */
/**************************************************************************
Duplicate a block of data, allocated from a memory heap. */
void*
mem_heap_dup(
/*=========*/
/* out, own: a copy of the data */
mem_heap_t* heap, /* in: memory heap where copy is allocated */
const void* data, /* in: data to be copied */
ulint len); /* in: length of data, in bytes */
#ifdef MEM_PERIODIC_CHECK #ifdef MEM_PERIODIC_CHECK
/********************************************************************** /**********************************************************************
Goes through the list of all allocated mem blocks, checks their magic Goes through the list of all allocated mem blocks, checks their magic
......
...@@ -110,8 +110,21 @@ mem_heap_strdup( ...@@ -110,8 +110,21 @@ mem_heap_strdup(
mem_heap_t* heap, /* in: memory heap where string is allocated */ mem_heap_t* heap, /* in: memory heap where string is allocated */
const char* str) /* in: string to be copied */ const char* str) /* in: string to be copied */
{ {
ulint len = strlen(str) + 1; return(mem_heap_dup(heap, str, strlen(str) + 1));
return(memcpy(mem_heap_alloc(heap, len), str, len)); }
/**************************************************************************
Duplicate a block of data, allocated from a memory heap. */
void*
mem_heap_dup(
/*=========*/
/* out, own: a copy of the data */
mem_heap_t* heap, /* in: memory heap where copy is allocated */
const void* data, /* in: data to be copied */
ulint len) /* in: length of data, in bytes */
{
return(memcpy(mem_heap_alloc(heap, len), data, len));
} }
/************************************************************************** /**************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment