int args(box_function_ctx_t *ctx, const char *args, const char *args_end) { uint32_t arg_count = mp_decode_array(&args); if (arg_count < 1) { return box_error_set(__FILE__, __LINE__, ER_PROC_C, "%s", "invalid argument count"); } if (mp_typeof(*args) != MP_UINT) { return box_error_set(__FILE__, __LINE__, ER_PROC_C, "%s", "first tuple field must be uint"); } uint32_t num = mp_decode_uint(&args); char tuple_buf[512]; char *d = tuple_buf; d = mp_encode_array(d, 2); d = mp_encode_uint(d, num); d = mp_encode_str(d, "hello", strlen("hello")); assert(d <= tuple_buf + sizeof(tuple_buf)); box_tuple_format_t *fmt = box_tuple_format_default(); box_tuple_t *tuple = box_tuple_new(fmt, tuple_buf, d); if (tuple == NULL) return -1; return box_return_tuple(ctx, tuple); }
int test_reload_fail(box_function_ctx_t *ctx, const char *args, const char *args_end) { char tuple_buf[64]; char *tuple_end = tuple_buf; tuple_end = mp_encode_array(tuple_end, 1); tuple_end = mp_encode_uint(tuple_end, 2); struct tuple *tuple = box_tuple_new(box_tuple_format_default(), tuple_buf, tuple_end); return box_return_tuple(ctx, tuple); }