Updated v2_0_c_overview (markdown)

Takatoshi Kondo
2020-06-30 23:13:18 +09:00
parent 6bee3a401a
commit 708d4d6c65
+2 -2
@@ -113,7 +113,7 @@ Those functions are corresponding to [msgpack format](https://github.com/msgpack
To pack STR, RAW(v4 format), BIN, and EXT, call `msgpack_pack_[str|v4raw|bin|ext]` to provide a size and then call `msgpack_pack_[str|v4raw|bin|ext]_body` to provide a payload. To pack ARRAY, call `msgpack_pack_array` to provide the number of elements and then call any `msgpack_pack_*` functions the number times. To pack MAP, call `msgpack_pack_map` to provide the number of elements and then call any `msgpack_pack_*` functions the number*2 times (key and value).
When you use packer as value (not pointer), you don't need to call destroy function. Be careful that [msgpack_packer_free](https://github.com/msgpack/msgpack-c/blob/master/include/msgpack/pack.h#L53) is not a destroy function for a packer as value. It is for [msgpack_packer_new](https://github.com/msgpack/msgpack-c/blob/master/include/msgpack/pack.h#L52). If you want to create a packer on heap, call `msgpack_packer_new` to create a packer and `msgpack_packer_free` to destroy(free) the packer.
When you use packer as value (not pointer), you don't need to call destroy function. Be careful that [msgpack_packer_free](https://github.com/msgpack/msgpack-c/blob/c_master/include/msgpack/pack.h#L53) is not a destroy function for a packer as value. It is for [msgpack_packer_new](https://github.com/msgpack/msgpack-c/blob/c_master/include/msgpack/pack.h#L52). If you want to create a packer on heap, call `msgpack_packer_new` to create a packer and `msgpack_packer_free` to destroy(free) the packer.
### Unpack
@@ -173,7 +173,7 @@ Now, msgpack_unpacker has enough buffer size. You can get buffer pointer using m
memcpy(msgpack_unpacker_buffer(&unp), data, request_size);
```
The number of writing bytes is might not always equal to reqest_size. See https://github.com/msgpack/msgpack-c/blob/master/example/c/lib_buffer_unpack.c.
The number of writing bytes is might not always equal to reqest_size. See https://github.com/msgpack/msgpack-c/blob/c_master/example/c/lib_buffer_unpack.c.
After writing, you need to notify the number of wrote bytes to msgpack_unpacker using msgpack_unpacker_buffer_consumed().