|
|
@@ -25,24 +25,21 @@ rt_bool_t js_message_send(const char *name, rt_uint8_t *data, rt_uint32_t size)
|
|
|
|
|
|
if (js_message_cb)
|
|
|
{
|
|
|
- struct js_message *msg = rt_malloc(sizeof(struct js_message));
|
|
|
- if (msg)
|
|
|
+ struct js_message msg;
|
|
|
+
|
|
|
+ msg.name = rt_strdup(name);
|
|
|
+ msg.size = size;
|
|
|
+ msg.data = rt_malloc(msg.size);
|
|
|
+ if (msg.data)
|
|
|
{
|
|
|
- msg->name = rt_strdup(name);
|
|
|
- msg->size = size;
|
|
|
- msg->data = rt_malloc(msg->size);
|
|
|
- if (msg->data)
|
|
|
- {
|
|
|
- rt_memcpy(msg->data, data, size);
|
|
|
- ret = js_send_callback(js_message_cb, msg, sizeof(struct js_message));
|
|
|
- }
|
|
|
+ rt_memcpy(msg.data, data, size);
|
|
|
+ ret = js_send_callback(js_message_cb, &msg, sizeof(struct js_message));
|
|
|
+ }
|
|
|
|
|
|
- if (!ret)
|
|
|
- {
|
|
|
- rt_free(msg->data);
|
|
|
- rt_free(msg->name);
|
|
|
- rt_free(msg);
|
|
|
- }
|
|
|
+ if (!ret)
|
|
|
+ {
|
|
|
+ rt_free(msg.data);
|
|
|
+ rt_free(msg.name);
|
|
|
}
|
|
|
}
|
|
|
|