|
|
|
@ -294,26 +294,42 @@ mem_strdupl( |
|
|
|
const char* str, /*!< in: string to be copied */ |
|
|
|
ulint len); /*!< in: length of str, in bytes */ |
|
|
|
|
|
|
|
/** Duplicates a NUL-terminated string, allocated from a memory heap. |
|
|
|
/** Duplicate a block of data, allocated from a memory heap. |
|
|
|
@param[in] heap memory heap where string is allocated |
|
|
|
@param[in] data block of data to be copied |
|
|
|
@param[in] len length of data, in bytes |
|
|
|
@return own: a copy of data */ |
|
|
|
inline |
|
|
|
void* |
|
|
|
mem_heap_dup(mem_heap_t* heap, const void* data, size_t len) |
|
|
|
{ |
|
|
|
return(memcpy(mem_heap_alloc(heap, len), data, len)); |
|
|
|
} |
|
|
|
|
|
|
|
/** Duplicate a NUL-terminated string, allocated from a memory heap. |
|
|
|
@param[in] heap memory heap where string is allocated |
|
|
|
@param[in] str string to be copied |
|
|
|
@return own: a copy of the string */ |
|
|
|
inline |
|
|
|
char* |
|
|
|
mem_heap_strdup( |
|
|
|
mem_heap_t* heap, |
|
|
|
const char* str); |
|
|
|
mem_heap_strdup(mem_heap_t* heap, const char* str) |
|
|
|
{ |
|
|
|
return(static_cast<char*>(mem_heap_dup(heap, str, strlen(str) + 1))); |
|
|
|
} |
|
|
|
|
|
|
|
/**********************************************************************//** |
|
|
|
Makes a NUL-terminated copy of a nonterminated string, |
|
|
|
allocated from a memory heap. |
|
|
|
@return own: a copy of the string */ |
|
|
|
UNIV_INLINE |
|
|
|
/** Duplicate a string, allocated from a memory heap. |
|
|
|
@param[in] heap memory heap where string is allocated |
|
|
|
@param[in] str string to be copied |
|
|
|
@param[in] len length of str, in bytes |
|
|
|
@return own: a NUL-terminated copy of str */ |
|
|
|
inline |
|
|
|
char* |
|
|
|
mem_heap_strdupl( |
|
|
|
/*=============*/ |
|
|
|
mem_heap_t* heap, /*!< in: memory heap where string is allocated */ |
|
|
|
const char* str, /*!< in: string to be copied */ |
|
|
|
ulint len); /*!< in: length of str, in bytes */ |
|
|
|
mem_heap_strdupl(mem_heap_t* heap, const char* str, size_t len) |
|
|
|
{ |
|
|
|
char* s = static_cast<char*>(mem_heap_alloc(heap, len + 1)); |
|
|
|
s[len] = 0; |
|
|
|
return(static_cast<char*>(memcpy(s, str, len))); |
|
|
|
} |
|
|
|
|
|
|
|
/**********************************************************************//** |
|
|
|
Concatenate two strings and return the result, using a memory heap. |
|
|
|
@ -325,16 +341,6 @@ mem_heap_strcat( |
|
|
|
const char* s1, /*!< in: string 1 */ |
|
|
|
const char* s2); /*!< in: string 2 */ |
|
|
|
|
|
|
|
/**********************************************************************//** |
|
|
|
Duplicate a block of data, allocated from a memory heap. |
|
|
|
@return own: a copy of the data */ |
|
|
|
void* |
|
|
|
mem_heap_dup( |
|
|
|
/*=========*/ |
|
|
|
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 */ |
|
|
|
|
|
|
|
/****************************************************************//** |
|
|
|
A simple sprintf replacement that dynamically allocates the space for the |
|
|
|
formatted string from the given heap. This supports a very limited set of |
|
|
|
|