mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-14 12:12:26 +00:00
DtMmdb: fix a crash occurs when creating bookmark.
This commit is contained in:
parent
f0123efa84
commit
121510cb72
5 changed files with 19 additions and 64 deletions
|
@ -91,7 +91,7 @@ oid_t::oid_t(const char* source, Boolean ascii_format, Boolean swap_order)
|
|||
memcpy((char*)&v_i_code, source, sizeof(v_i_code));
|
||||
|
||||
if ( swap_order == true )
|
||||
ORDER_SWAP_LONG(v_i_code);
|
||||
ORDER_SWAP_I_CODE_T(v_i_code);
|
||||
|
||||
} else {
|
||||
istringstream in((char*)source);
|
||||
|
@ -248,7 +248,7 @@ void oid_t::to_char_string(char* sink, Boolean swap_order) const
|
|||
|
||||
if ( swap_order == true ) {
|
||||
i_code_t x = v_i_code;
|
||||
ORDER_SWAP_LONG(x);
|
||||
ORDER_SWAP_I_CODE_T(x);
|
||||
memcpy(sink, (char*)&x, sizeof(x));
|
||||
} else
|
||||
memcpy(sink, (char*)&v_i_code, sizeof(v_i_code));
|
||||
|
|
|
@ -65,6 +65,7 @@ typedef unsigned short c_code_t;
|
|||
typedef mmdb_pos_t i_code_t;
|
||||
|
||||
#define OID_T_SZ (sizeof(i_code_t))
|
||||
#define ORDER_SWAP_I_CODE_T(x) ORDER_SWAP(i_code_t, x)
|
||||
|
||||
/*************************************
|
||||
// class code root
|
||||
|
|
|
@ -118,7 +118,7 @@ public:
|
|||
};
|
||||
|
||||
void swap_order() {
|
||||
ORDER_SWAP_LONG(fwd_ptr);
|
||||
ORDER_SWAP_MMDB_POS_T(fwd_ptr);
|
||||
ORDER_SWAP_UINT(header.int_view);
|
||||
swapped = true;
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue