mirror of
https://github.com/msgpack/msgpack-c.git
synced 2026-01-11 00:24:16 +01:00
MSVC2005 compatibility (@hotpepsi++)
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
#define MSGPACK_OBJECT_H__
|
||||
|
||||
#include "msgpack/zone.h"
|
||||
#include "msgpack/sysdep.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
4
c/zone.c
4
c/zone.c
@@ -104,7 +104,6 @@ static inline void init_finalizer_array(msgpack_zone_finalizer_array* fa)
|
||||
|
||||
static inline void call_finalizer_array(msgpack_zone_finalizer_array* fa)
|
||||
{
|
||||
// 逆順に呼び出し
|
||||
msgpack_zone_finalizer* fin = fa->tail;
|
||||
for(; fin != fa->array; --fin) {
|
||||
(*(fin-1)->func)((fin-1)->data);
|
||||
@@ -132,9 +131,6 @@ bool msgpack_zone_push_finalizer_expand(msgpack_zone* zone,
|
||||
|
||||
size_t nnext;
|
||||
if(nused == 0) {
|
||||
// 初回の呼び出し:fa->tail == fa->end == fa->array == NULL
|
||||
|
||||
// glibcは72バイト以下のmallocが高速
|
||||
nnext = (sizeof(msgpack_zone_finalizer) < 72/2) ?
|
||||
72 / sizeof(msgpack_zone_finalizer) : 8;
|
||||
|
||||
|
||||
1
c/zone.h
1
c/zone.h
@@ -18,6 +18,7 @@
|
||||
#ifndef MSGPACK_ZONE_H__
|
||||
#define MSGPACK_ZONE_H__
|
||||
|
||||
#include "msgpack/sysdep.h"
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
@@ -29,11 +29,15 @@ inline std::vector<T>& operator>> (object o, std::vector<T>& v)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
v.resize(o.via.array.size);
|
||||
object* p = o.via.array.ptr;
|
||||
object* const pend = o.via.array.ptr + o.via.array.size;
|
||||
T* it = &v.front();
|
||||
for(; p < pend; ++p, ++it) {
|
||||
p->convert(it);
|
||||
if(o.via.array.size > 0) {
|
||||
object* p = o.via.array.ptr;
|
||||
object* const pend = o.via.array.ptr + o.via.array.size;
|
||||
T* it = &v[0];
|
||||
do {
|
||||
p->convert(it);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,17 @@ typedef unsigned int _msgpack_atomic_counter_t;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
/* numeric_limits<T>::min,max */
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user