diff options
Diffstat (limited to 'innobase/include/ut0mem.h')
-rw-r--r-- | innobase/include/ut0mem.h | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/innobase/include/ut0mem.h b/innobase/include/ut0mem.h index 7bee83b151e..74357f6bf13 100644 --- a/innobase/include/ut0mem.h +++ b/innobase/include/ut0mem.h @@ -18,15 +18,15 @@ extern ulint ut_total_allocated_memory; UNIV_INLINE void* -ut_memcpy(void* dest, void* sour, ulint n); +ut_memcpy(void* dest, const void* sour, ulint n); UNIV_INLINE void* -ut_memmove(void* dest, void* sour, ulint n); +ut_memmove(void* dest, const void* sour, ulint n); UNIV_INLINE int -ut_memcmp(void* str1, void* str2, ulint n); +ut_memcmp(const void* str1, const void* str2, ulint n); /************************************************************************** @@ -38,8 +38,10 @@ ut_malloc_low( /*==========*/ /* out, own: allocated memory */ ulint n, /* in: number of bytes to allocate */ - ibool set_to_zero); /* in: TRUE if allocated memory should be set + ibool set_to_zero, /* in: TRUE if allocated memory should be set to zero if UNIV_SET_MEM_TO_ZERO is defined */ + ibool assert_on_error); /* in: if TRUE, we crash mysqld if the memory + cannot be allocated */ /************************************************************************** Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is defined. */ @@ -50,6 +52,16 @@ ut_malloc( /* out, own: allocated memory */ ulint n); /* in: number of bytes to allocate */ /************************************************************************** +Tests if malloc of n bytes would succeed. ut_malloc() asserts if memory runs +out. It cannot be used if we want to return an error message. Prints to +stderr a message if fails. */ + +ibool +ut_test_malloc( +/*===========*/ + /* out: TRUE if succeeded */ + ulint n); /* in: try to allocate this many bytes */ +/************************************************************************** Frees a memory bloock allocated with ut_malloc. */ void @@ -96,7 +108,7 @@ ut_free_all_mem(void); UNIV_INLINE char* -ut_strcpy(char* dest, char* sour); +ut_strcpy(char* dest, const char* sour); UNIV_INLINE ulint @@ -104,10 +116,10 @@ ut_strlen(const char* str); UNIV_INLINE int -ut_strcmp(void* str1, void* str2); +ut_strcmp(const void* str1, const void* str2); /************************************************************************** -Determine the length of a string when it is quoted with ut_strcpyq(). */ +Compute strlen(ut_strcpyq(str, q)). */ UNIV_INLINE ulint ut_strlenq( @@ -117,7 +129,9 @@ ut_strlenq( char q); /* in: the quote character */ /************************************************************************** -Make a quoted copy of a string. */ +Make a quoted copy of a NUL-terminated string. Leading and trailing +quotes will not be included; only embedded quotes will be escaped. +See also ut_strlenq() and ut_memcpyq(). */ char* ut_strcpyq( @@ -128,7 +142,9 @@ ut_strcpyq( const char* src); /* in: null-terminated string */ /************************************************************************** -Make a quoted copy of a fixed-length string. */ +Make a quoted copy of a fixed-length string. Leading and trailing +quotes will not be included; only embedded quotes will be escaped. +See also ut_strlenq() and ut_strcpyq(). */ char* ut_memcpyq( |