1
/*****************************************************************************
3
Copyright (C) 1995, 2009, Innobase Oy. All Rights Reserved.
5
This program is free software; you can redistribute it and/or modify it under
6
the terms of the GNU General Public License as published by the Free Software
7
Foundation; version 2 of the License.
9
This program is distributed in the hope that it will be useful, but WITHOUT
10
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
17
*****************************************************************************/
19
/******************************************************************//**
20
@file mach/mach0data.c
21
Utilities for converting data from the database file
22
to the machine format.
24
Created 11/28/1995 Heikki Tuuri
25
***********************************************************************/
27
#include "mach0data.h"
30
#include "mach0data.ic"
33
/*********************************************************//**
34
Reads a ulint in a compressed form if the log record fully contains it.
35
@return pointer to end of the stored field, NULL if not complete */
38
mach_parse_compressed(
39
/*==================*/
40
byte* ptr, /*!< in: pointer to buffer from where to read */
41
byte* end_ptr,/*!< in: pointer to end of the buffer */
42
ulint* val) /*!< out: read value (< 2^32) */
46
ut_ad(ptr && end_ptr && val);
53
flag = mach_read_from_1(ptr);
59
} else if (flag < 0xC0UL) {
60
if (end_ptr < ptr + 2) {
64
*val = mach_read_from_2(ptr) & 0x7FFFUL;
68
} else if (flag < 0xE0UL) {
69
if (end_ptr < ptr + 3) {
73
*val = mach_read_from_3(ptr) & 0x3FFFFFUL;
76
} else if (flag < 0xF0UL) {
77
if (end_ptr < ptr + 4) {
81
*val = mach_read_from_4(ptr) & 0x1FFFFFFFUL;
85
ut_ad(flag == 0xF0UL);
87
if (end_ptr < ptr + 5) {
91
*val = mach_read_from_4(ptr + 1);