MySQL  8.0.19
Source Code Documentation
ut0mem.h File Reference
#include "univ.i"
#include "os0event.h"
#include "ut0mutex.h"
#include "ut0mem.ic"

Go to the source code of this file.

Functions

UNIV_INLINE void * ut_memcpy (void *dest, const void *src, ulint n)
 Wrapper for memcpy(3). More...
 
UNIV_INLINE void * ut_memmove (void *dest, const void *src, ulint n)
 Wrapper for memmove(3). More...
 
UNIV_INLINE int ut_memcmp (const void *str1, const void *str2, ulint n)
 Wrapper for memcmp(3). More...
 
UNIV_INLINE char * ut_strcpy (char *dest, const char *src)
 Wrapper for strcpy(3). More...
 
UNIV_INLINE ulint ut_strlen (const char *str)
 Wrapper for strlen(3). More...
 
UNIV_INLINE int ut_strcmp (const char *str1, const char *str2)
 Wrapper for strcmp(3). More...
 
ulint ut_strlcpy (char *dst, const char *src, ulint size)
 Copies up to size - 1 characters from the NUL-terminated string src to dst, NUL-terminating the result. More...
 
char * ut_str3cat (const char *s1, const char *s2, const char *s3)
 
UNIV_INLINE ulint ut_raw_to_hex (const void *raw, ulint raw_size, char *hex, ulint hex_size)
 Converts a raw binary data to a NUL-terminated hex string. More...
 
UNIV_INLINE ulint ut_str_sql_format (const char *str, ulint str_len, char *buf, ulint buf_size)
 Adds single quotes to the start and end of string and escapes any quotes by doubling them. More...
 

Detailed Description

Memory primitives

Created 5/30/1994 Heikki Tuuri

Function Documentation

◆ ut_memcmp()

UNIV_INLINE int ut_memcmp ( const void *  str1,
const void *  str2,
ulint  n 
)

Wrapper for memcmp(3).

Compare memory areas.

Parameters
[in]str1first memory block to compare
[in]str2second memory block to compare
[in]nnumber of bytes to compare
Returns
negative, 0, or positive if str1 is smaller, equal, or greater than str2, respectively.

◆ ut_memcpy()

UNIV_INLINE void* ut_memcpy ( void *  dest,
const void *  src,
ulint  n 
)

Wrapper for memcpy(3).

Copy memory area when the source and target are not overlapping.

Parameters
[in,out]destcopy to
[in]srccopy from
[in]nnumber of bytes to copy
Returns
dest

◆ ut_memmove()

UNIV_INLINE void* ut_memmove ( void *  dest,
const void *  src,
ulint  n 
)

Wrapper for memmove(3).

Copy memory area when the source and target are overlapping.

Parameters
[in,out]destMove to
[in]srcMove from
[in]nnumber of bytes to move
Returns
dest

◆ ut_raw_to_hex()

UNIV_INLINE ulint ut_raw_to_hex ( const void *  raw,
ulint  raw_size,
char *  hex,
ulint  hex_size 
)

Converts a raw binary data to a NUL-terminated hex string.

The output is truncated if there is not enough space in "hex", make sure "hex_size" is at least (2 * raw_size + 1) if you do not want this to happen. Returns the actual number of characters written to "hex" (including the NUL).

Parameters
[in]rawraw data
[in]raw_size"raw" length in bytes
[out]hexhex string
[in]hex_size"hex" size in bytes
Returns
number of chars written

◆ ut_str3cat()

char* ut_str3cat ( const char *  s1,
const char *  s2,
const char *  s3 
)

◆ ut_str_sql_format()

UNIV_INLINE ulint ut_str_sql_format ( const char *  str,
ulint  str_len,
char *  buf,
ulint  buf_size 
)

Adds single quotes to the start and end of string and escapes any quotes by doubling them.

Returns the number of bytes that were written to "buf" (including the terminating NUL). If buf_size is too small then the trailing bytes from "str" are discarded.

Parameters
[in]strstring
[in]str_lenstring length in bytes
[out]bufoutput buffer
[in]buf_sizeoutput buffer size in bytes
Returns
number of bytes that were written

◆ ut_strcmp()

UNIV_INLINE int ut_strcmp ( const char *  str1,
const char *  str2 
)

Wrapper for strcmp(3).

Compare NUL-terminated strings.

Parameters
[in]str1first string to compare
[in]str2second string to compare
Returns
negative, 0, or positive if str1 is smaller, equal, or greater than str2, respectively.

◆ ut_strcpy()

UNIV_INLINE char* ut_strcpy ( char *  dest,
const char *  src 
)

Wrapper for strcpy(3).

Copy a NUL-terminated string.

Parameters
[in,out]destDestination to copy to
[in]srcSource to copy from
Returns
dest

◆ ut_strlcpy()

ulint ut_strlcpy ( char *  dst,
const char *  src,
ulint  size 
)

Copies up to size - 1 characters from the NUL-terminated string src to dst, NUL-terminating the result.

Returns strlen(src), so truncation occurred if the return value >= size.

Returns
strlen(src) in: size of destination buffer

Returns strlen(src), so truncation occurred if the return value >= size.

Returns
strlen(src)

◆ ut_strlen()

UNIV_INLINE ulint ut_strlen ( const char *  str)

Wrapper for strlen(3).

Determine the length of a NUL-terminated string.

Parameters
[in]strstring
Returns
length of the string in bytes, excluding the terminating NUL