Skip to content

Commit de3c2b9

Browse files
committed
refactor C code
fixes #137
1 parent 3cef27b commit de3c2b9

File tree

3 files changed

+3
-37
lines changed

3 files changed

+3
-37
lines changed

msgpack/pack.h

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -39,40 +39,6 @@ typedef struct msgpack_packer {
3939

4040
typedef struct Packer Packer;
4141

42-
static inline int msgpack_pack_int(msgpack_packer* pk, int d);
43-
static inline int msgpack_pack_long(msgpack_packer* pk, long d);
44-
static inline int msgpack_pack_long_long(msgpack_packer* pk, long long d);
45-
static inline int msgpack_pack_unsigned_short(msgpack_packer* pk, unsigned short d);
46-
static inline int msgpack_pack_unsigned_int(msgpack_packer* pk, unsigned int d);
47-
static inline int msgpack_pack_unsigned_long(msgpack_packer* pk, unsigned long d);
48-
//static inline int msgpack_pack_unsigned_long_long(msgpack_packer* pk, unsigned long long d);
49-
50-
static inline int msgpack_pack_uint8(msgpack_packer* pk, uint8_t d);
51-
static inline int msgpack_pack_uint16(msgpack_packer* pk, uint16_t d);
52-
static inline int msgpack_pack_uint32(msgpack_packer* pk, uint32_t d);
53-
static inline int msgpack_pack_uint64(msgpack_packer* pk, uint64_t d);
54-
static inline int msgpack_pack_int8(msgpack_packer* pk, int8_t d);
55-
static inline int msgpack_pack_int16(msgpack_packer* pk, int16_t d);
56-
static inline int msgpack_pack_int32(msgpack_packer* pk, int32_t d);
57-
static inline int msgpack_pack_int64(msgpack_packer* pk, int64_t d);
58-
59-
static inline int msgpack_pack_float(msgpack_packer* pk, float d);
60-
static inline int msgpack_pack_double(msgpack_packer* pk, double d);
61-
62-
static inline int msgpack_pack_nil(msgpack_packer* pk);
63-
static inline int msgpack_pack_true(msgpack_packer* pk);
64-
static inline int msgpack_pack_false(msgpack_packer* pk);
65-
66-
static inline int msgpack_pack_array(msgpack_packer* pk, unsigned int n);
67-
68-
static inline int msgpack_pack_map(msgpack_packer* pk, unsigned int n);
69-
70-
static inline int msgpack_pack_raw(msgpack_packer* pk, size_t l);
71-
static inline int msgpack_pack_bin(msgpack_packer* pk, size_t l);
72-
static inline int msgpack_pack_raw_body(msgpack_packer* pk, const void* b, size_t l);
73-
74-
static inline int msgpack_pack_ext(msgpack_packer* pk, char typecode, size_t l);
75-
7642
static inline int msgpack_pack_write(msgpack_packer* pk, const char *data, size_t l)
7743
{
7844
char* buf = pk->buf;

msgpack/unpack.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static inline int unpack_callback_uint64(unpack_user* u, uint64_t d, msgpack_unp
6969
if (d > LONG_MAX) {
7070
p = PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)d);
7171
} else {
72-
p = PyInt_FromSize_t((size_t)d);
72+
p = PyInt_FromLong((long)d);
7373
}
7474
if (!p)
7575
return -1;
@@ -100,7 +100,7 @@ static inline int unpack_callback_int64(unpack_user* u, int64_t d, msgpack_unpac
100100
{
101101
PyObject *p;
102102
if (d > LONG_MAX || d < LONG_MIN) {
103-
p = PyLong_FromLongLong((unsigned PY_LONG_LONG)d);
103+
p = PyLong_FromLongLong((PY_LONG_LONG)d);
104104
} else {
105105
p = PyInt_FromLong((long)d);
106106
}

msgpack/unpack_template.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static inline PyObject* unpack_data(unpack_context* ctx)
7070
return (ctx)->stack[0].obj;
7171
}
7272

73-
static inline PyObject* unpack_clear(unpack_context *ctx)
73+
static inline void unpack_clear(unpack_context *ctx)
7474
{
7575
Py_CLEAR(ctx->stack[0].obj);
7676
}

0 commit comments

Comments
 (0)