DtMmdb: fix a crash occurs when creating bookmark.
This commit is contained in:
@@ -77,48 +77,18 @@
|
||||
|
||||
/* little endian to/from big endian swap macros. */
|
||||
|
||||
#define ORDER_SWAP_LONG(x) \
|
||||
{ \
|
||||
long tmp_long = x; \
|
||||
((unsigned char*)&x)[0] = ((unsigned char*)&tmp_long)[3]; \
|
||||
((unsigned char*)&x)[1] = ((unsigned char*)&tmp_long)[2]; \
|
||||
((unsigned char*)&x)[2] = ((unsigned char*)&tmp_long)[1]; \
|
||||
((unsigned char*)&x)[3] = ((unsigned char*)&tmp_long)[0]; \
|
||||
#define ORDER_SWAP(type, value) \
|
||||
{ \
|
||||
type tmp = value; \
|
||||
int n = sizeof(type) - 1; \
|
||||
for (int i = 0; i <= n; ++i) \
|
||||
((uint8_t *)&value)[i] = ((uint8_t *)&tmp)[n - i]; \
|
||||
}
|
||||
|
||||
#define ORDER_SWAP_FLOAT(x) \
|
||||
{ \
|
||||
float tmp_float = x; \
|
||||
((unsigned char*)&x)[0] = ((unsigned char*)&tmp_float)[3]; \
|
||||
((unsigned char*)&x)[1] = ((unsigned char*)&tmp_float)[2]; \
|
||||
((unsigned char*)&x)[2] = ((unsigned char*)&tmp_float)[1]; \
|
||||
((unsigned char*)&x)[3] = ((unsigned char*)&tmp_float)[0]; \
|
||||
}
|
||||
|
||||
#define ORDER_SWAP_INT(x) \
|
||||
{ \
|
||||
int tmp_uint = x; \
|
||||
((unsigned char*)&x)[0] = ((unsigned char*)&tmp_uint)[3]; \
|
||||
((unsigned char*)&x)[1] = ((unsigned char*)&tmp_uint)[2]; \
|
||||
((unsigned char*)&x)[2] = ((unsigned char*)&tmp_uint)[1]; \
|
||||
((unsigned char*)&x)[3] = ((unsigned char*)&tmp_uint)[0]; \
|
||||
}
|
||||
|
||||
#define ORDER_SWAP_UINT(x) \
|
||||
{ \
|
||||
unsigned int tmp_uint = x; \
|
||||
((unsigned char*)&x)[0] = ((unsigned char*)&tmp_uint)[3]; \
|
||||
((unsigned char*)&x)[1] = ((unsigned char*)&tmp_uint)[2]; \
|
||||
((unsigned char*)&x)[2] = ((unsigned char*)&tmp_uint)[1]; \
|
||||
((unsigned char*)&x)[3] = ((unsigned char*)&tmp_uint)[0]; \
|
||||
}
|
||||
|
||||
#define ORDER_SWAP_USHORT(x) \
|
||||
{ \
|
||||
unsigned short tmp_ushort = x; \
|
||||
((unsigned char*)&x)[0] = ((unsigned char*)&tmp_ushort)[1]; \
|
||||
((unsigned char*)&x)[1] = ((unsigned char*)&tmp_ushort)[0]; \
|
||||
}
|
||||
|
||||
#define ORDER_SWAP_FLOAT(x) ORDER_SWAP(float, x)
|
||||
#define ORDER_SWAP_LONG(x) ORDER_SWAP(long, x)
|
||||
#define ORDER_SWAP_INT(x) ORDER_SWAP(int, x)
|
||||
#define ORDER_SWAP_UINT(x) ORDER_SWAP(unsigned int, x)
|
||||
#define ORDER_SWAP_USHORT(x) ORDER_SWAP(unsigned short, x)
|
||||
#define ORDER_SWAP_MMDB_POS_T(x) ORDER_SWAP(mmdb_pos_t, x)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -47,8 +47,10 @@
|
||||
#define _types_h 1
|
||||
|
||||
#ifdef C_API
|
||||
#include <stdint.h>
|
||||
#include "utility/c_iostream.h"
|
||||
#else
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
#endif
|
||||
@@ -60,15 +62,7 @@ typedef char Boolean;
|
||||
typedef void* voidPtr;
|
||||
typedef char* charPtr;
|
||||
|
||||
typedef short s_int16;
|
||||
typedef unsigned short u_int16;
|
||||
|
||||
typedef int s_int32;
|
||||
typedef unsigned int u_int32;
|
||||
|
||||
typedef long s_long32;
|
||||
|
||||
typedef float s_float32;
|
||||
typedef intptr_t mmdb_pos_t;
|
||||
|
||||
enum io_status { done, fail };
|
||||
|
||||
@@ -76,14 +70,4 @@ class root;
|
||||
typedef Boolean (*cmp_func_ptr_t)(const void*, const void*);
|
||||
typedef void (*app_func_ptr_t)(const void*);
|
||||
typedef void (*print_func_ptr_t)(ostream&, const void*);
|
||||
|
||||
//enum Boolean { true, false };
|
||||
|
||||
#if !defined(__linux__) && !defined(CSRG_BASED)
|
||||
typedef long mmdb_pos_t;
|
||||
#else
|
||||
typedef int mmdb_pos_t;
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user