MySQL 8.0.40
Source Code Documentation
ut0mem.h File Reference

Memory primitives. More...

#include "univ.i"
#include "os0event.h"
#include "ut0mutex.h"
#include "ut0mem.ic"

Go to the source code of this file.

Namespaces

namespace  ut
 This file contains a set of libraries providing overloads for regular dynamic allocation routines which allow for opt-in memory instrumentation through performance schema memory engine (PFS).
 

Functions

static void * ut_memcpy (void *dest, const void *src, ulint n)
 Wrapper for memcpy(3). More...
 
static void * ut_memmove (void *dest, const void *src, ulint n)
 Wrapper for memmove(3). More...
 
static int ut_memcmp (const void *str1, const void *str2, ulint n)
 Wrapper for memcmp(3). More...
 
static char * ut_strcpy (char *dest, const char *src)
 Wrapper for strcpy(3). More...
 
static ulint ut_strlen (const char *str)
 Wrapper for strlen(3). More...
 
static 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)
 
static 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...
 
static 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...
 
template<typename T >
bool ut::is_aligned_as (void const *const ptr)
 Checks if the pointer has address aligned properly for a given type. More...
 
bool ut::is_zeros (const void *start, size_t number_of_bytes)
 Checks if memory range is all zeros. More...
 

Detailed Description

Memory primitives.

Created 5/30/1994 Heikki Tuuri

Function Documentation

◆ ut_memcmp()

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

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()

static void * ut_memcpy ( void *  dest,
const void *  src,
ulint  n 
)
inlinestatic

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()

static void * ut_memmove ( void *  dest,
const void *  src,
ulint  n 
)
inlinestatic

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()

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

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()

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

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()

static int ut_strcmp ( const char *  str1,
const char *  str2 
)
inlinestatic

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()

static char * ut_strcpy ( char *  dest,
const char *  src 
)
inlinestatic

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)
Parameters
dstin: destination buffer
srcin: source buffer
sizein: size of destination buffer

◆ ut_strlen()

static ulint ut_strlen ( const char *  str)
inlinestatic

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