Exemple #1
0
static inline int template_callback_array(unpack_user* u, unsigned int n, msgpack_object* o)
{
    o->type = MSGPACK_OBJECT_ARRAY;
    o->via.array.size = 0;
    o->via.array.ptr = (msgpack_object*)msgpack_zone_malloc(u->z, n*sizeof(msgpack_object));
    if(o->via.array.ptr == NULL) { return -1; }
    return 0;
}
Exemple #2
0
static inline int template_callback_map(unpack_user* u, unsigned int n, msgpack_object* o)
{
    o->type = MSGPACK_OBJECT_MAP;
    o->via.map.size = 0;
    o->via.map.ptr = (msgpack_object_kv*)msgpack_zone_malloc(u->z, n*sizeof(msgpack_object_kv));
    if(o->via.map.ptr == NULL) { return -1; }
    return 0;
}
Exemple #3
0
static inline int template_callback_map(unpack_user* u, unsigned int n, msgpack_object* o)
{
    unsigned int size;
    o->type = MSGPACK_OBJECT_MAP;
    o->via.map.size = 0;
    size = n*sizeof(msgpack_object_kv);
    if (size / sizeof(msgpack_object_kv) != n) {
        // integer overflow
        return MSGPACK_UNPACK_NOMEM_ERROR;
    }
    o->via.map.ptr = (msgpack_object_kv*)msgpack_zone_malloc(u->z, size);
    if(o->via.map.ptr == NULL) { return MSGPACK_UNPACK_NOMEM_ERROR; }
    return 0;
}