File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,46 @@ int msgpack_pack_object(msgpack_packer* pk, msgpack_object d)
125125 }
126126}
127127
128+ int msgpack_object_init (msgpack_object * d , void * data , size_t size , int type )
129+ {
130+ d -> type = type ;
131+ switch (type ) {
132+ case MSGPACK_OBJECT_STR :
133+ {
134+ d -> via .str .ptr = (char * )data ;
135+ d -> via .str .size = size ;
136+ break ;
137+ }
138+ case MSGPACK_OBJECT_BIN :
139+ {
140+ d -> type = type ;
141+ d -> via .bin .ptr = (char * )data ;
142+ d -> via .bin .size = size ;
143+ break ;
144+ }
145+ case MSGPACK_OBJECT_ARRAY :
146+ {
147+ d -> via .array .ptr = (msgpack_object * )data ;
148+ d -> via .array .size = size ;
149+ break ;
150+ }
151+ case MSGPACK_OBJECT_MAP :
152+ {
153+ d -> via .map .ptr = (msgpack_object_kv * ) data ;
154+ d -> via .map .size = size ;
155+ break ;
156+ }
157+ default :
158+ {
159+ // Other types are not supported and need to be initialized manually.
160+ d -> type = MSGPACK_OBJECT_NIL ;
161+ return -1 ;
162+ }
163+ }
164+ return 0 ;
165+
166+ }
167+
128168#if !defined(_KERNEL_MODE )
129169
130170static void msgpack_object_bin_print (FILE * out , const char * ptr , size_t size )
You can’t perform that action at this time.
0 commit comments