mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-17 03:03:24 +02:00
Do not interleave code and declarations in C files
Avoid C99 style to interleave code and declarations in order to compile msgpackc with Visual Studion < 2013
This commit is contained in:
@@ -52,6 +52,7 @@ void unpack(receiver* r) {
|
||||
msgpack_unpack_return ret;
|
||||
char* buf;
|
||||
size_t recv_len;
|
||||
int recv_count = 0;
|
||||
|
||||
msgpack_unpacked_init(&result);
|
||||
if (msgpack_unpacker_buffer_capacity(unp) < EACH_RECV_SIZE) {
|
||||
@@ -64,7 +65,6 @@ void unpack(receiver* r) {
|
||||
msgpack_unpacker_buffer_consumed(unp, recv_len);
|
||||
|
||||
|
||||
int recv_count = 0;
|
||||
while (recv_len > 0) {
|
||||
int i = 0;
|
||||
printf("receive count: %d %zd bytes received.:\n", recv_count++, recv_len);
|
||||
|
@@ -3,12 +3,15 @@
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* msgpack::sbuffer is a simple buffer implementation. */
|
||||
msgpack_sbuffer sbuf;
|
||||
msgpack_packer pk;
|
||||
msgpack_zone mempool;
|
||||
msgpack_object deserialized;
|
||||
|
||||
/* msgpack::sbuffer is a simple buffer implementation. */
|
||||
msgpack_sbuffer_init(&sbuf);
|
||||
|
||||
/* serialize values into the buffer using msgpack_sbuffer_write callback function. */
|
||||
msgpack_packer pk;
|
||||
msgpack_packer_init(&pk, &sbuf, msgpack_sbuffer_write);
|
||||
|
||||
msgpack_pack_array(&pk, 3);
|
||||
@@ -19,10 +22,8 @@ int main(void)
|
||||
|
||||
/* deserialize the buffer into msgpack_object instance. */
|
||||
/* deserialized object is valid during the msgpack_zone instance alive. */
|
||||
msgpack_zone mempool;
|
||||
msgpack_zone_init(&mempool, 2048);
|
||||
|
||||
msgpack_object deserialized;
|
||||
msgpack_unpack(sbuf.data, sbuf.size, NULL, &mempool, &deserialized);
|
||||
|
||||
/* print the deserialized object. */
|
||||
|
@@ -1,13 +1,16 @@
|
||||
#include <msgpack.h>
|
||||
#include <assert.h>
|
||||
|
||||
void test()
|
||||
{
|
||||
size_t size = 10000000;
|
||||
msgpack_sbuffer buf;
|
||||
msgpack_packer * pk;
|
||||
size_t upk_pos = 0;
|
||||
msgpack_unpacked msg;
|
||||
|
||||
msgpack_sbuffer_init(&buf);
|
||||
|
||||
msgpack_packer * pk = msgpack_packer_new(&buf, msgpack_sbuffer_write);
|
||||
pk = msgpack_packer_new(&buf, msgpack_sbuffer_write);
|
||||
|
||||
msgpack_pack_array(pk, size);
|
||||
{
|
||||
@@ -17,9 +20,6 @@ void test()
|
||||
}
|
||||
msgpack_packer_free(pk);
|
||||
|
||||
|
||||
size_t upk_pos = 0;
|
||||
msgpack_unpacked msg;
|
||||
msgpack_unpacked_init(&msg);
|
||||
|
||||
while (msgpack_unpack_next(&msg, buf.data, buf.size, &upk_pos)) {
|
||||
|
@@ -1,14 +1,17 @@
|
||||
#include <msgpack.h>
|
||||
#include <assert.h>
|
||||
|
||||
void test()
|
||||
{
|
||||
uint64_t test_u64 = 0xFFF0000000000001LL;
|
||||
size_t size = 10000000;
|
||||
msgpack_sbuffer buf;
|
||||
msgpack_packer * pk;
|
||||
size_t upk_pos = 0;
|
||||
msgpack_unpacked msg;
|
||||
|
||||
msgpack_sbuffer_init(&buf);
|
||||
|
||||
msgpack_packer * pk = msgpack_packer_new(&buf, msgpack_sbuffer_write);
|
||||
pk = msgpack_packer_new(&buf, msgpack_sbuffer_write);
|
||||
|
||||
msgpack_pack_array(pk, size);
|
||||
{
|
||||
@@ -18,9 +21,6 @@ void test()
|
||||
}
|
||||
msgpack_packer_free(pk);
|
||||
|
||||
|
||||
size_t upk_pos = 0;
|
||||
msgpack_unpacked msg;
|
||||
msgpack_unpacked_init(&msg);
|
||||
|
||||
while (msgpack_unpack_next(&msg, buf.data, buf.size, &upk_pos)) {
|
||||
|
Reference in New Issue
Block a user