Extracted ctx from allocator macro.
Signed-off-by: Yilin Sun <imi415@imi.moe>
This commit is contained in:
parent
60a5a9fb07
commit
7e1f11ab84
|
@ -10,11 +10,11 @@
|
|||
#define NH_COMMAND_TIMEOUT_MSEC 30000
|
||||
#define NH_COMMAND_REQ_MEM_SIZE 256
|
||||
|
||||
#define NH_CTRL_API_CREATE_ALLOCATOR(allocator_name) \
|
||||
#define NH_CTRL_API_CREATE_ALLOCATOR(allocator_name, allocator_ctx) \
|
||||
ProtobufCAllocator allocator_name = { \
|
||||
.alloc = nh_ctrl_api_protobuf_allocate, \
|
||||
.free = nh_ctrl_api_protobuf_free, \
|
||||
.allocator_data = api, \
|
||||
.allocator_data = allocator_ctx, \
|
||||
}
|
||||
|
||||
#define NH_CTRL_API_TAKE_SEM(s_api, timeout) s_api->osa->sem_take(s_api->osa->user_data, s_api->p_sem_req, timeout)
|
||||
|
@ -61,7 +61,7 @@ free_sem_req:
|
|||
nh_ret_t nh_ctrl_api_get_mac_address(nh_ctrl_api_t *api, uint8_t *mac_addr, nh_ctrl_wifi_mode_t mode) {
|
||||
nh_ret_t ret = NH_RET_SUCCESS;
|
||||
|
||||
NH_CTRL_API_CREATE_ALLOCATOR(c_alloc);
|
||||
NH_CTRL_API_CREATE_ALLOCATOR(c_alloc, api);
|
||||
ret = NH_CTRL_API_TAKE_SEM(api, NH_COMMAND_TIMEOUT_MSEC);
|
||||
if (ret != NH_RET_SUCCESS) return ret;
|
||||
|
||||
|
@ -107,7 +107,7 @@ give_sem_exit:
|
|||
nh_ret_t nh_ctrl_api_get_ap_scan_list(nh_ctrl_api_t *api, nh_ctrl_api_ap_scan_list_cb_t cb) {
|
||||
nh_ret_t ret = NH_RET_SUCCESS;
|
||||
|
||||
NH_CTRL_API_CREATE_ALLOCATOR(c_alloc);
|
||||
NH_CTRL_API_CREATE_ALLOCATOR(c_alloc, api);
|
||||
ret = NH_CTRL_API_TAKE_SEM(api, NH_COMMAND_TIMEOUT_MSEC);
|
||||
if (ret != NH_RET_SUCCESS) return ret;
|
||||
|
||||
|
@ -180,7 +180,7 @@ nh_ret_t nh_ctrl_api_connect_ap(nh_ctrl_api_t *api, nh_ctrl_ap_conn_params_t *pa
|
|||
nh_ctrl_ap_conn_result_t *result) {
|
||||
nh_ret_t ret = NH_RET_SUCCESS;
|
||||
|
||||
NH_CTRL_API_CREATE_ALLOCATOR(c_alloc);
|
||||
NH_CTRL_API_CREATE_ALLOCATOR(c_alloc, api);
|
||||
ret = NH_CTRL_API_TAKE_SEM(api, NH_COMMAND_TIMEOUT_MSEC);
|
||||
if (ret != NH_RET_SUCCESS) return ret;
|
||||
|
||||
|
@ -262,7 +262,7 @@ void nh_ctrl_api_task(nh_ctrl_api_t *api) {
|
|||
}
|
||||
|
||||
static nh_ret_t nh_ctrl_api_parse_event(nh_ctrl_api_t *api, CtrlMsgId *event_id, uint8_t *buf, uint32_t buf_len) {
|
||||
NH_CTRL_API_CREATE_ALLOCATOR(c_alloc);
|
||||
NH_CTRL_API_CREATE_ALLOCATOR(c_alloc, api);
|
||||
|
||||
CtrlMsg *msg = ctrl_msg__unpack(&c_alloc, buf_len, buf);
|
||||
if (msg == NULL) {
|
||||
|
|
Loading…
Reference in New Issue