MySQL 8.4.0
Source Code Documentation
ut0mem.ic File Reference

Memory primitives. More...

#include "mach0data.h"
#include "ut0byte.h"

Macros

#define MK_UINT16(a, b)   (((uint16)(b)) << 8 | (uint16)(a))
 
#define UINT16_GET_A(u)   ((unsigned char)((u)&0xFF))
 
#define UINT16_GET_B(u)   ((unsigned char)((u) >> 8))
 
#define MK_ALL_UINT16_WITH_A(a)
 
#define LOOP_READ_BYTES(ASSIGN)
 

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...
 
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...
 

Detailed Description

Memory primitives.

Created 5/30/1994 Heikki Tuuri

Macro Definition Documentation

◆ LOOP_READ_BYTES

#define LOOP_READ_BYTES (   ASSIGN)
Value:
for (i = 0; i < read_bytes; i++) { \
ASSIGN; \
hex += 2; \
rawc++; \
}
static int read_bytes(connection_descriptor const *rfd, char *p, uint32_t n, server *s, int64_t *ret)
Reads n bytes from connection rfd without buffering reads.
Definition: xcom_transport.cc:1024

◆ MK_ALL_UINT16_WITH_A

#define MK_ALL_UINT16_WITH_A (   a)
Value:
MK_UINT16(a, '0'), MK_UINT16(a, '1'), MK_UINT16(a, '2'), MK_UINT16(a, '3'), \
MK_UINT16(a, '4'), MK_UINT16(a, '5'), MK_UINT16(a, '6'), \
MK_UINT16(a, '7'), MK_UINT16(a, '8'), MK_UINT16(a, '9'), \
MK_UINT16(a, 'A'), MK_UINT16(a, 'B'), MK_UINT16(a, 'C'), \
MK_UINT16(a, 'D'), MK_UINT16(a, 'E'), MK_UINT16(a, 'F')
#define MK_UINT16(a, b)

◆ MK_UINT16

#define MK_UINT16 (   a,
 
)    (((uint16)(b)) << 8 | (uint16)(a))

◆ UINT16_GET_A

#define UINT16_GET_A (   u)    ((unsigned char)((u)&0xFF))

◆ UINT16_GET_B

#define UINT16_GET_B (   u)    ((unsigned char)((u) >> 8))

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

Returns
number of chars written
Parameters
rawin: raw data
raw_sizein: "raw" length in bytes
hexout: hex string
hex_sizein: "hex" size in bytes

◆ 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.

Returns
number of bytes that were written
Parameters
strin: string
str_lenin: string length in bytes
bufout: output buffer
buf_sizein: output buffer size in bytes

◆ 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_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