mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +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));
|
memcpy((char*)&v_i_code, source, sizeof(v_i_code));
|
||||||
|
|
||||||
if ( swap_order == true )
|
if ( swap_order == true )
|
||||||
ORDER_SWAP_LONG(v_i_code);
|
ORDER_SWAP_I_CODE_T(v_i_code);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
istringstream in((char*)source);
|
istringstream in((char*)source);
|
||||||
|
@ -248,7 +248,7 @@ void oid_t::to_char_string(char* sink, Boolean swap_order) const
|
||||||
|
|
||||||
if ( swap_order == true ) {
|
if ( swap_order == true ) {
|
||||||
i_code_t x = v_i_code;
|
i_code_t x = v_i_code;
|
||||||
ORDER_SWAP_LONG(x);
|
ORDER_SWAP_I_CODE_T(x);
|
||||||
memcpy(sink, (char*)&x, sizeof(x));
|
memcpy(sink, (char*)&x, sizeof(x));
|
||||||
} else
|
} else
|
||||||
memcpy(sink, (char*)&v_i_code, sizeof(v_i_code));
|
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;
|
typedef mmdb_pos_t i_code_t;
|
||||||
|
|
||||||
#define OID_T_SZ (sizeof(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
|
// class code root
|
||||||
|
|
|
@ -118,7 +118,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
void swap_order() {
|
void swap_order() {
|
||||||
ORDER_SWAP_LONG(fwd_ptr);
|
ORDER_SWAP_MMDB_POS_T(fwd_ptr);
|
||||||
ORDER_SWAP_UINT(header.int_view);
|
ORDER_SWAP_UINT(header.int_view);
|
||||||
swapped = true;
|
swapped = true;
|
||||||
};
|
};
|
||||||
|
|
|
@ -77,48 +77,18 @@
|
||||||
|
|
||||||
/* little endian to/from big endian swap macros. */
|
/* little endian to/from big endian swap macros. */
|
||||||
|
|
||||||
#define ORDER_SWAP_LONG(x) \
|
#define ORDER_SWAP(type, value) \
|
||||||
{ \
|
{ \
|
||||||
long tmp_long = x; \
|
type tmp = value; \
|
||||||
((unsigned char*)&x)[0] = ((unsigned char*)&tmp_long)[3]; \
|
int n = sizeof(type) - 1; \
|
||||||
((unsigned char*)&x)[1] = ((unsigned char*)&tmp_long)[2]; \
|
for (int i = 0; i <= n; ++i) \
|
||||||
((unsigned char*)&x)[2] = ((unsigned char*)&tmp_long)[1]; \
|
((uint8_t *)&value)[i] = ((uint8_t *)&tmp)[n - i]; \
|
||||||
((unsigned char*)&x)[3] = ((unsigned char*)&tmp_long)[0]; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ORDER_SWAP_FLOAT(x) \
|
#define ORDER_SWAP_FLOAT(x) ORDER_SWAP(float, x)
|
||||||
{ \
|
#define ORDER_SWAP_LONG(x) ORDER_SWAP(long, x)
|
||||||
float tmp_float = x; \
|
#define ORDER_SWAP_INT(x) ORDER_SWAP(int, x)
|
||||||
((unsigned char*)&x)[0] = ((unsigned char*)&tmp_float)[3]; \
|
#define ORDER_SWAP_UINT(x) ORDER_SWAP(unsigned int, x)
|
||||||
((unsigned char*)&x)[1] = ((unsigned char*)&tmp_float)[2]; \
|
#define ORDER_SWAP_USHORT(x) ORDER_SWAP(unsigned short, x)
|
||||||
((unsigned char*)&x)[2] = ((unsigned char*)&tmp_float)[1]; \
|
#define ORDER_SWAP_MMDB_POS_T(x) ORDER_SWAP(mmdb_pos_t, x)
|
||||||
((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]; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,10 @@
|
||||||
#define _types_h 1
|
#define _types_h 1
|
||||||
|
|
||||||
#ifdef C_API
|
#ifdef C_API
|
||||||
|
#include <stdint.h>
|
||||||
#include "utility/c_iostream.h"
|
#include "utility/c_iostream.h"
|
||||||
#else
|
#else
|
||||||
|
#include <cstdint>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
#endif
|
#endif
|
||||||
|
@ -60,15 +62,7 @@ typedef char Boolean;
|
||||||
typedef void* voidPtr;
|
typedef void* voidPtr;
|
||||||
typedef char* charPtr;
|
typedef char* charPtr;
|
||||||
|
|
||||||
typedef short s_int16;
|
typedef intptr_t mmdb_pos_t;
|
||||||
typedef unsigned short u_int16;
|
|
||||||
|
|
||||||
typedef int s_int32;
|
|
||||||
typedef unsigned int u_int32;
|
|
||||||
|
|
||||||
typedef long s_long32;
|
|
||||||
|
|
||||||
typedef float s_float32;
|
|
||||||
|
|
||||||
enum io_status { done, fail };
|
enum io_status { done, fail };
|
||||||
|
|
||||||
|
@ -76,14 +70,4 @@ class root;
|
||||||
typedef Boolean (*cmp_func_ptr_t)(const void*, const void*);
|
typedef Boolean (*cmp_func_ptr_t)(const void*, const void*);
|
||||||
typedef void (*app_func_ptr_t)(const void*);
|
typedef void (*app_func_ptr_t)(const void*);
|
||||||
typedef void (*print_func_ptr_t)(ostream&, 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
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue