InnoDB Plugin  1.0
Macros | Functions
ut0mem.ic File Reference
#include "ut0byte.h"
#include "mach0data.h"
Include dependency graph for ut0mem.ic:
This graph shows which files directly or indirectly include this file:

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

UNIV_INLINE void * ut_memcpy (void *dest, const void *sour, ulint n)
UNIV_INLINE void * ut_memmove (void *dest, const void *sour, ulint n)
UNIV_INLINE int ut_memcmp (const void *str1, const void *str2, ulint n)
UNIV_INLINE char * ut_strcpy (char *dest, const char *sour)
UNIV_INLINE ulint ut_strlen (const char *str)
UNIV_INLINE int ut_strcmp (const char *str1, const char *str2)
UNIV_INLINE ulint ut_raw_to_hex (const void *raw, ulint raw_size, char *hex, ulint hex_size)
UNIV_INLINE ulint ut_str_sql_format (const char *str, ulint str_len, char *buf, ulint buf_size)

Detailed Description

Memory primitives

Created 5/30/1994 Heikki Tuuri

Macro Definition Documentation

#define LOOP_READ_BYTES (   ASSIGN)
Value:
for (i = 0; i < read_bytes; i++) { \
ASSIGN; \
hex += 2; \
rawc++; \
}
#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')

Function Documentation

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

Wrapper for memcmp(3). Compare memory areas.

Parameters
str1in: first memory block to compare
str2in: second memory block to compare
nin: number of bytes to compare
Returns
negative, 0, or positive if str1 is smaller, equal, or greater than str2, respectively.
UNIV_INLINE void* ut_memcpy ( void *  dest,
const void *  sour,
ulint  n 
)
Wrapper for memcpy(3).  Copy memory area when the source and

target are not overlapping.

Parameters
destin: copy to
sourin: copy from
nin: number of bytes to copy
Returns
dest
UNIV_INLINE void* ut_memmove ( void *  dest,
const void *  sour,
ulint  n 
)
Wrapper for memmove(3).  Copy memory area when the source and

target are overlapping.

Parameters
destin: copy to
sourin: copy from
nin: number of bytes to copy
Returns
dest
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).

Returns
number of chars written
Parameters
rawin: raw data
raw_sizein: "raw" length in bytes
hexout: hex string
hex_sizein: "hex" size in bytes
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.

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
UNIV_INLINE int ut_strcmp ( const char *  str1,
const char *  str2 
)

Wrapper for strcmp(3). Compare NUL-terminated strings.

Parameters
str1in: first string to compare
str2in: second string to compare
Returns
negative, 0, or positive if str1 is smaller, equal, or greater than str2, respectively.
UNIV_INLINE char* ut_strcpy ( char *  dest,
const char *  sour 
)

Wrapper for strcpy(3). Copy a NUL-terminated string.

Parameters
destin: copy to
sourin: copy from
Returns
dest
UNIV_INLINE ulint ut_strlen ( const char *  str)

Wrapper for strlen(3). Determine the length of a NUL-terminated string.

Parameters
strin: string
Returns
length of the string in bytes, excluding the terminating NUL