Created
June 17, 2014 02:31
-
-
Save redboltz/7981e65ed8d4962fed60 to your computer and use it in GitHub Desktop.
msgpack-c: error data is not consumed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <msgpack.h> | |
#include <stdio.h> | |
#include <assert.h> | |
int main(void) | |
{ | |
msgpack_unpacker* unp = msgpack_unpacker_new(100); | |
msgpack_unpacked result; | |
bool ret; | |
char* buf; | |
printf("unp:%p\n", unp); | |
assert(unp); | |
buf = msgpack_unpacker_buffer(unp); | |
printf("buf:%p\n", buf); | |
assert(buf); | |
printf("cap:%d\n", msgpack_unpacker_buffer_capacity(unp)); | |
assert(msgpack_unpacker_buffer_capacity(unp) >= 3); | |
buf[0] = 0xc0; | |
buf[1] = 0xc1; | |
buf[2] = 0xc0; | |
msgpack_unpacker_buffer_consumed(unp, 3); | |
msgpack_unpacked_init(&result); | |
ret = msgpack_unpacker_next(unp, &result); | |
printf("ret:%d\n", ret); | |
ret = msgpack_unpacker_next(unp, &result); | |
printf("ret:%d\n", ret); | |
ret = msgpack_unpacker_next(unp, &result); | |
printf("ret:%d\n", ret); | |
msgpack_unpacked_destroy(&result); | |
msgpack_unpacker_destroy(unp); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment