1
/**********************************************************************
2
Utilities for converting data from the database file
7
Created 11/28/1995 Heikki Tuuri
8
***********************************************************************/
10
#include "mach0data.h"
13
#include "mach0data.ic"
16
/*************************************************************
17
Reads a ulint in a compressed form if the log record fully contains it. */
20
mach_parse_compressed(
21
/*==================*/
22
/* out: pointer to end of the stored field, NULL if
24
byte* ptr, /* in: pointer to buffer from where to read */
25
byte* end_ptr,/* in: pointer to end of the buffer */
26
ulint* val) /* out: read value (< 2^32) */
30
ut_ad(ptr && end_ptr && val);
37
flag = mach_read_from_1(ptr);
43
} else if (flag < 0xC0UL) {
44
if (end_ptr < ptr + 2) {
48
*val = mach_read_from_2(ptr) & 0x7FFFUL;
52
} else if (flag < 0xE0UL) {
53
if (end_ptr < ptr + 3) {
57
*val = mach_read_from_3(ptr) & 0x3FFFFFUL;
60
} else if (flag < 0xF0UL) {
61
if (end_ptr < ptr + 4) {
65
*val = mach_read_from_4(ptr) & 0x1FFFFFFFUL;
69
ut_ad(flag == 0xF0UL);
71
if (end_ptr < ptr + 5) {
75
*val = mach_read_from_4(ptr + 1);
80
/*************************************************************
81
Reads a dulint in a compressed form if the log record fully contains it. */
84
mach_dulint_parse_compressed(
85
/*=========================*/
86
/* out: pointer to end of the stored field, NULL if
88
byte* ptr, /* in: pointer to buffer from where to read */
89
byte* end_ptr,/* in: pointer to end of the buffer */
90
dulint* val) /* out: read value */
96
ut_ad(ptr && end_ptr && val);
98
if (end_ptr < ptr + 5) {
103
high = mach_read_compressed(ptr);
105
size = mach_get_compressed_size(high);
109
if (end_ptr < ptr + 4) {
114
low = mach_read_from_4(ptr);
116
*val = ut_dulint_create(high, low);