Re-org memory allocation interfaces, add --stack-size and --heap-size option (#193)
This commit is contained in:
@ -6,7 +6,6 @@
|
||||
#include "app_manager.h"
|
||||
#include "app_manager_host.h"
|
||||
#include "bh_queue.h"
|
||||
#include "bh_memory.h"
|
||||
#include "bh_thread.h"
|
||||
#include "bi-inc/attr_container.h"
|
||||
#include "event.h"
|
||||
|
||||
@ -18,6 +18,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define APP_MGR_MALLOC wasm_runtime_malloc
|
||||
#define APP_MGR_FREE wasm_runtime_free
|
||||
|
||||
/* bh_printf is defined in each platform */
|
||||
#define app_manager_printf bh_printf
|
||||
|
||||
|
||||
@ -9,7 +9,6 @@
|
||||
#include "app_manager.h"
|
||||
#include "app_manager_export.h"
|
||||
#include "coap_ext.h"
|
||||
#include "bh_memory.h"
|
||||
#include "bh_thread.h"
|
||||
|
||||
/* host communication interface */
|
||||
@ -66,7 +65,7 @@ static int on_imrt_link_byte_arrive(unsigned char ch, recv_context_t *ctx)
|
||||
ctx->message.payload_size = 0;
|
||||
|
||||
if (ctx->message.payload) {
|
||||
bh_free(ctx->message.payload);
|
||||
APP_MGR_FREE(ctx->message.payload);
|
||||
ctx->message.payload = NULL;
|
||||
}
|
||||
|
||||
@ -117,7 +116,7 @@ static int on_imrt_link_byte_arrive(unsigned char ch, recv_context_t *ctx)
|
||||
app_manager_printf("##On byte arrive: payload_size: %d\n",
|
||||
ctx->message.payload_size);
|
||||
if (ctx->message.payload) {
|
||||
bh_free(ctx->message.payload);
|
||||
APP_MGR_FREE(ctx->message.payload);
|
||||
ctx->message.payload = NULL;
|
||||
}
|
||||
|
||||
@ -137,7 +136,7 @@ static int on_imrt_link_byte_arrive(unsigned char ch, recv_context_t *ctx)
|
||||
|
||||
if (ctx->message.message_type != INSTALL_WASM_APP) {
|
||||
ctx->message.payload =
|
||||
(char *) bh_malloc(ctx->message.payload_size);
|
||||
(char *) APP_MGR_MALLOC(ctx->message.payload_size);
|
||||
if (!ctx->message.payload) {
|
||||
ctx->phase = Phase_Non_Start;
|
||||
return 0;
|
||||
@ -222,7 +221,7 @@ int aee_host_msg_callback(void *msg, uint16_t msg_len)
|
||||
printf("unexpected host msg type: %d\n", msg_type);
|
||||
}
|
||||
|
||||
bh_free(recv_ctx.message.payload);
|
||||
APP_MGR_FREE(recv_ctx.message.payload);
|
||||
recv_ctx.message.payload = NULL;
|
||||
recv_ctx.message.payload_size = 0;
|
||||
}
|
||||
|
||||
@ -75,16 +75,16 @@ app_instance_free_ble_msg(char *msg)
|
||||
dev_info = (ble_device_info *) ble_msg->payload;
|
||||
|
||||
if (dev_info->scan_response != NULL)
|
||||
bh_free(dev_info->scan_response);
|
||||
APP_MGR_FREE(dev_info->scan_response);
|
||||
|
||||
if (dev_info->private_data != NULL)
|
||||
bh_free(dev_info->private_data);
|
||||
APP_MGR_FREE(dev_info->private_data);
|
||||
|
||||
if (dev_info->adv_data != NULL)
|
||||
bh_free(dev_info->adv_data);
|
||||
APP_MGR_FREE(dev_info->adv_data);
|
||||
|
||||
if (dev_info != NULL)
|
||||
bh_free(dev_info);
|
||||
APP_MGR_FREE(dev_info);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@ -8,7 +8,6 @@
|
||||
#include "event.h"
|
||||
|
||||
#include "app_manager.h"
|
||||
#include "bh_memory.h"
|
||||
#include "coap_ext.h"
|
||||
|
||||
typedef struct _subscribe {
|
||||
@ -38,7 +37,7 @@ static bool find_subscriber(event_reg_t * reg, uint32 id, bool remove_found)
|
||||
else
|
||||
reg->subscribers = next;
|
||||
|
||||
bh_free(c);
|
||||
APP_MGR_FREE(c);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -77,7 +76,7 @@ bool am_register_event(const char *url, uint32_t reg_client)
|
||||
|
||||
if (current == NULL) {
|
||||
if (NULL
|
||||
== (current = (event_reg_t *) bh_malloc(
|
||||
== (current = (event_reg_t *) APP_MGR_MALLOC(
|
||||
offsetof(event_reg_t, url) + strlen(url) + 1))) {
|
||||
app_manager_printf("am_register_event: malloc fail\n");
|
||||
return false;
|
||||
@ -92,7 +91,7 @@ bool am_register_event(const char *url, uint32_t reg_client)
|
||||
if (find_subscriber(current, reg_client, false)) {
|
||||
return true;
|
||||
} else {
|
||||
subscribe_t * s = (subscribe_t*) bh_malloc(sizeof(subscribe_t));
|
||||
subscribe_t * s = (subscribe_t*) APP_MGR_MALLOC(sizeof(subscribe_t));
|
||||
if (s == NULL)
|
||||
return false;
|
||||
|
||||
@ -128,7 +127,7 @@ bool am_unregister_event(const char *url, uint32_t reg_client)
|
||||
pre->next = next;
|
||||
else
|
||||
g_events = next;
|
||||
bh_free(current);
|
||||
APP_MGR_FREE(current);
|
||||
current = next;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@
|
||||
#include "app_manager_host.h"
|
||||
#include "event.h"
|
||||
#include "bi-inc/attr_container.h"
|
||||
#include "bh_memory.h"
|
||||
#include "coap_ext.h"
|
||||
|
||||
#if 0
|
||||
@ -21,7 +20,7 @@ bool send_coap_packet_to_host(coap_packet_t * packet)
|
||||
return false;
|
||||
|
||||
app_manager_host_send_msg(buf, size);
|
||||
bh_free(buf);
|
||||
APP_MGR_FREE(buf);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ get_class_qname(const JeffString *pname, const JeffString *cname)
|
||||
{
|
||||
unsigned int length = pname->length ? pname->length + 2 + cname->length
|
||||
: cname->length + 1;
|
||||
char *buf = bh_malloc(length), *p;
|
||||
char *buf = APP_MGR_MALLOC(length), *p;
|
||||
|
||||
if (!buf)
|
||||
return NULL;
|
||||
@ -166,7 +166,7 @@ send_exception_event_to_host(const char *applet_name, const char *exc_name)
|
||||
}
|
||||
|
||||
url_len = strlen("/exception/") + strlen(applet_name);
|
||||
url = bh_malloc(url_len + 1);
|
||||
url = APP_MGR_MALLOC(url_len + 1);
|
||||
if (!url) {
|
||||
app_manager_printf("Send exception to host fail: allocate memory");
|
||||
goto fail;
|
||||
@ -182,7 +182,7 @@ send_exception_event_to_host(const char *applet_name, const char *exc_name)
|
||||
|
||||
app_send_request_msg_to_host(&msg);
|
||||
|
||||
bh_free(url);
|
||||
APP_MGR_FREE(url);
|
||||
|
||||
fail:
|
||||
attr_container_destroy(payload);
|
||||
@ -208,7 +208,7 @@ check_exception()
|
||||
/* Send exception event to host */
|
||||
if (qname_buf) {
|
||||
send_exception_event_to_host(app_manager_get_module_name(Module_Jeff), qname_buf);
|
||||
bh_free(qname_buf);
|
||||
APP_MGR_FREE(qname_buf);
|
||||
}
|
||||
|
||||
/* Uninstall the applet */
|
||||
@ -455,17 +455,17 @@ check_exception()
|
||||
|
||||
fail:
|
||||
if (dev_info->scan_response != NULL) {
|
||||
bh_free(dev_info->scan_response);
|
||||
APP_MGR_FREE(dev_info->scan_response);
|
||||
}
|
||||
if (dev_info->private_data != NULL) {
|
||||
bh_free(dev_info->private_data);
|
||||
APP_MGR_FREE(dev_info->private_data);
|
||||
}
|
||||
|
||||
if (dev_info->adv_data != NULL) {
|
||||
bh_free(dev_info->adv_data);
|
||||
APP_MGR_FREE(dev_info->adv_data);
|
||||
}
|
||||
if (dev_info != NULL) {
|
||||
bh_free(dev_info);
|
||||
APP_MGR_FREE(dev_info);
|
||||
}
|
||||
|
||||
}
|
||||
@ -479,16 +479,16 @@ check_exception()
|
||||
dev_info = (ble_device_info *) ble_msg->payload;
|
||||
|
||||
if (dev_info->scan_response != NULL)
|
||||
bh_free(dev_info->scan_response);
|
||||
APP_MGR_FREE(dev_info->scan_response);
|
||||
|
||||
if (dev_info->private_data != NULL)
|
||||
bh_free(dev_info->private_data);
|
||||
APP_MGR_FREE(dev_info->private_data);
|
||||
|
||||
if (dev_info->adv_data != NULL)
|
||||
bh_free(dev_info->adv_data);
|
||||
APP_MGR_FREE(dev_info->adv_data);
|
||||
|
||||
if (dev_info != NULL)
|
||||
bh_free(dev_info);
|
||||
APP_MGR_FREE(dev_info);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -500,7 +500,7 @@ check_exception()
|
||||
case APPLET_REQUEST:
|
||||
{
|
||||
bh_request_msg_t *req_msg = (bh_request_msg_t *)msg->payload;
|
||||
bh_free(req_msg);
|
||||
APP_MGR_FREE(req_msg);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -516,7 +516,7 @@ check_exception()
|
||||
attr_container_t *event = sensor_event->event;
|
||||
|
||||
attr_container_destroy(event);
|
||||
bh_free(sensor_event);
|
||||
APP_MGR_FREE(sensor_event);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -525,7 +525,7 @@ check_exception()
|
||||
{
|
||||
if (msg->payload) {
|
||||
app_instance_free_ble_msg(msg->payload);
|
||||
bh_free(msg->payload);
|
||||
APP_MGR_FREE(msg->payload);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -541,7 +541,7 @@ check_exception()
|
||||
}
|
||||
}
|
||||
|
||||
bh_free(msg);
|
||||
APP_MGR_FREE(msg);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -609,7 +609,7 @@ check_exception()
|
||||
fail2:
|
||||
jeff_runtime_pop_local_object_ref(1);
|
||||
fail1:
|
||||
bh_free(req_msg);
|
||||
APP_MGR_FREE(req_msg);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -633,7 +633,7 @@ check_exception()
|
||||
bool ret = attr_container_to_attr_obj(event, &sensor->event);
|
||||
|
||||
attr_container_destroy(event);
|
||||
bh_free(sensor_event);
|
||||
APP_MGR_FREE(sensor_event);
|
||||
|
||||
if (ret) {
|
||||
/* Call Sensor.callOnSensorEvent() method */
|
||||
@ -649,7 +649,7 @@ check_exception()
|
||||
{
|
||||
if (msg->payload) {
|
||||
app_instance_process_ble_msg(msg->payload);
|
||||
bh_free(msg->payload);
|
||||
APP_MGR_FREE(msg->payload);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -678,7 +678,7 @@ check_exception()
|
||||
}
|
||||
}
|
||||
|
||||
bh_free(msg);
|
||||
APP_MGR_FREE(msg);
|
||||
}
|
||||
|
||||
static JeffClassHeaderLinked*
|
||||
@ -837,7 +837,7 @@ check_exception()
|
||||
|
||||
/* TODO: convert bpk file to Jeff file */
|
||||
main_file_len = bpk_file_len;
|
||||
main_file = bh_malloc(main_file_len);
|
||||
main_file = APP_MGR_MALLOC(main_file_len);
|
||||
if (!main_file) {
|
||||
SEND_ERR_RESPONSE(msg->mid, "Install Applet failed: allocate memory failed.");
|
||||
return false;
|
||||
@ -866,7 +866,7 @@ check_exception()
|
||||
/* Create module data */
|
||||
size = offsetof(module_data, module_name) + strlen(applet_name) + 1;
|
||||
size = align_uint(size, 4);
|
||||
m_data = bh_malloc(size + sizeof(jeff_applet_data));
|
||||
m_data = APP_MGR_MALLOC(size + sizeof(jeff_applet_data));
|
||||
if (!m_data) {
|
||||
SEND_ERR_RESPONSE(msg->mid, "Install Applet failed: allocate memory failed.");
|
||||
goto fail2;
|
||||
@ -888,7 +888,7 @@ check_exception()
|
||||
/* Create applet permissions */
|
||||
applet_perm = attr_container_get_as_string(attr_cont, "perm");
|
||||
if (applet_perm != NULL) {
|
||||
applet_data->perms = bh_malloc(strlen(applet_perm) + 1);
|
||||
applet_data->perms = APP_MGR_MALLOC(strlen(applet_perm) + 1);
|
||||
if (!applet_data->perms) {
|
||||
SEND_ERR_RESPONSE(msg->mid, "Install Applet failed: allocate memory for applet permissions failed.");
|
||||
goto fail3;
|
||||
@ -993,16 +993,16 @@ check_exception()
|
||||
bh_queue_destroy(m_data->queue, NULL);
|
||||
|
||||
fail3_1:
|
||||
bh_free(applet_data->perms);
|
||||
APP_MGR_FREE(applet_data->perms);
|
||||
|
||||
fail3:
|
||||
bh_free(applet_data);
|
||||
APP_MGR_FREE(applet_data);
|
||||
|
||||
fail2:
|
||||
jeff_runtime_unload(main_file);
|
||||
|
||||
fail1:
|
||||
bh_free(main_file);
|
||||
APP_MGR_FREE(main_file);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -1014,7 +1014,7 @@ check_exception()
|
||||
|
||||
/* Unload Jeff main file and free it */
|
||||
jeff_runtime_unload(applet_data->main_file);
|
||||
bh_free(applet_data->main_file);
|
||||
APP_MGR_FREE(applet_data->main_file);
|
||||
|
||||
/* Destroy queue */
|
||||
bh_queue_destroy(m_data->queue, app_instance_queue_free_callback);
|
||||
@ -1027,8 +1027,8 @@ check_exception()
|
||||
|
||||
/* Remove module data from module data list and free it */
|
||||
app_manager_del_module_data(m_data);
|
||||
bh_free(applet_data->perms);
|
||||
bh_free(m_data);
|
||||
APP_MGR_FREE(applet_data->perms);
|
||||
APP_MGR_FREE(m_data);
|
||||
}
|
||||
|
||||
/* Uninstall Java Applet */
|
||||
@ -1476,7 +1476,7 @@ check_exception()
|
||||
}
|
||||
|
||||
/* Create queue message for tool agent */
|
||||
if (!(tool_agent_msg = bh_malloc(sizeof(bh_queue_msg_t)))) {
|
||||
if (!(tool_agent_msg = APP_MGR_MALLOC(sizeof(bh_queue_msg_t)))) {
|
||||
SEND_ERR_RESPONSE(mid, "Send request to tool agent failed: allocate memory failed");
|
||||
return false;
|
||||
}
|
||||
@ -1487,9 +1487,9 @@ check_exception()
|
||||
req_msg_len = sizeof(bh_request_msg_t) + strlen(p) + 1 + attr_cont_len;
|
||||
|
||||
/* Create request message */
|
||||
if (!(req_msg = bh_malloc(req_msg_len))) {
|
||||
if (!(req_msg = APP_MGR_MALLOC(req_msg_len))) {
|
||||
SEND_ERR_RESPONSE(mid, "Send request to applet failed: allocate memory failed");
|
||||
bh_free(tool_agent_msg);
|
||||
APP_MGR_FREE(tool_agent_msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1511,8 +1511,8 @@ check_exception()
|
||||
tool_agent_msg->payload_size = req_msg_len;
|
||||
tool_agent_msg->payload = (char*)req_msg;
|
||||
if (!bh_queue_send_message(applet_data->tool_agent_queue, tool_agent_msg)) {
|
||||
bh_free(req_msg);
|
||||
bh_free(tool_agent_msg);
|
||||
APP_MGR_FREE(req_msg);
|
||||
APP_MGR_FREE(tool_agent_msg);
|
||||
SEND_ERR_RESPONSE
|
||||
(mid, "Send request to tool agent failed: send queue msg failed.");
|
||||
return false;
|
||||
@ -1693,16 +1693,16 @@ check_exception()
|
||||
goto fail;
|
||||
}
|
||||
|
||||
bh_free(req_msg);
|
||||
bh_free(msg);
|
||||
APP_MGR_FREE(req_msg);
|
||||
APP_MGR_FREE(msg);
|
||||
return;
|
||||
|
||||
fail:
|
||||
bh_queue_exit_loop_run(queue);
|
||||
bh_free(req_msg);
|
||||
APP_MGR_FREE(req_msg);
|
||||
}
|
||||
|
||||
bh_free(msg);
|
||||
APP_MGR_FREE(msg);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1712,10 +1712,10 @@ check_exception()
|
||||
|
||||
if (msg->message_type == JDWP_REQUEST) {
|
||||
bh_request_msg_t *req_msg = (bh_request_msg_t*)msg->payload;
|
||||
bh_free(req_msg);
|
||||
APP_MGR_FREE(req_msg);
|
||||
}
|
||||
|
||||
bh_free(msg);
|
||||
APP_MGR_FREE(msg);
|
||||
}
|
||||
|
||||
#endif /* BEIHAI_ENABLE_TOOL_AGENT != 0 */
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
#include "app_manager.h"
|
||||
#include "app_manager_host.h"
|
||||
#include "bh_queue.h"
|
||||
#include "bh_memory.h"
|
||||
#include "bh_thread.h"
|
||||
#include "bi-inc/attr_container.h"
|
||||
#include "event.h"
|
||||
@ -32,7 +31,7 @@ void module_data_list_destroy()
|
||||
if (module_data_list) {
|
||||
while (module_data_list) {
|
||||
module_data *p = module_data_list->next;
|
||||
bh_free(module_data_list);
|
||||
APP_MGR_FREE(module_data_list);
|
||||
module_data_list = p;
|
||||
}
|
||||
}
|
||||
@ -197,7 +196,7 @@ void release_module(module_data *m_data)
|
||||
|
||||
destroy_module_timer_ctx(m_data->id);
|
||||
|
||||
bh_free(m_data);
|
||||
APP_MGR_FREE(m_data);
|
||||
}
|
||||
|
||||
int check_modules_timer_expiry()
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
#include "bh_queue.h"
|
||||
#include "bi-inc/attr_container.h"
|
||||
#include "bh_thread.h"
|
||||
#include "bh_memory.h"
|
||||
#include "coap_ext.h"
|
||||
#include "event.h"
|
||||
#include "watchdog.h"
|
||||
@ -551,12 +550,7 @@ cleanup_app_resource(module_data *m_data)
|
||||
static bool
|
||||
wasm_app_module_init(void)
|
||||
{
|
||||
/* Initialize WASM VM*/
|
||||
if (!wasm_runtime_init()) {
|
||||
app_manager_printf("WASM runtime environment initialization failed.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* wasm runtime is already initialized by main func */
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -776,7 +770,7 @@ wasm_app_module_install(request_t * msg)
|
||||
/* Create module data including the wasm_app_data as its internal_data*/
|
||||
m_data_size = offsetof(module_data, module_name) + strlen(m_name) + 1;
|
||||
m_data_size = align_uint(m_data_size, 4);
|
||||
m_data = bh_malloc(m_data_size + sizeof(wasm_data));
|
||||
m_data = APP_MGR_MALLOC(m_data_size + sizeof(wasm_data));
|
||||
if (!m_data) {
|
||||
SEND_ERR_RESPONSE(msg->mid, "Install WASM app failed: allocate memory failed.");
|
||||
goto fail;
|
||||
@ -1096,7 +1090,7 @@ wasm_app_module_on_install_request_byte_arrive(uint8 ch,
|
||||
recv_ctx.message.request_url_len =
|
||||
ntohs(recv_ctx.message.request_url_len);
|
||||
recv_ctx.message.request_url =
|
||||
bh_malloc(recv_ctx.message.request_url_len + 1);
|
||||
APP_MGR_MALLOC(recv_ctx.message.request_url_len + 1);
|
||||
if (NULL == recv_ctx.message.request_url) {
|
||||
app_manager_printf("Allocate memory failed!\n");
|
||||
goto fail;
|
||||
@ -1177,7 +1171,7 @@ wasm_app_module_on_install_request_byte_arrive(uint8 ch,
|
||||
uint8 section_type = ch;
|
||||
if (section_type <= SECTION_TYPE_DATA) {
|
||||
wasm_section_t *new_section;
|
||||
if (!(new_section = (wasm_section_t *) bh_malloc(sizeof(wasm_section_t)))) {
|
||||
if (!(new_section = (wasm_section_t *) APP_MGR_MALLOC(sizeof(wasm_section_t)))) {
|
||||
app_manager_printf("Allocate memory failed!\n");
|
||||
goto fail;
|
||||
}
|
||||
@ -1226,7 +1220,7 @@ wasm_app_module_on_install_request_byte_arrive(uint8 ch,
|
||||
|
||||
if ((byte & 0x80) == 0) {
|
||||
/* leb128 encoded section size parsed done */
|
||||
if (!(section->section_body = bh_malloc(section->section_body_size))) {
|
||||
if (!(section->section_body = APP_MGR_MALLOC(section->section_body_size))) {
|
||||
app_manager_printf("Allocate memory failed!\n");
|
||||
goto fail;
|
||||
}
|
||||
@ -1248,7 +1242,7 @@ wasm_app_module_on_install_request_byte_arrive(uint8 ch,
|
||||
if (recv_ctx.total_received_size == request_total_size) {
|
||||
/* whole wasm app received */
|
||||
if (module_wasm_app_handle_install_msg(&recv_ctx.message)) {
|
||||
bh_free(recv_ctx.message.request_url);
|
||||
APP_MGR_FREE(recv_ctx.message.request_url);
|
||||
recv_ctx.message.request_url = NULL;
|
||||
memset(&recv_ctx, 0, sizeof(recv_ctx));
|
||||
return true;
|
||||
@ -1297,7 +1291,7 @@ wasm_app_module_on_install_request_byte_arrive(uint8 ch,
|
||||
if (aot_file_cur_offset % 4)
|
||||
return true;
|
||||
|
||||
if (!(cur_section = (aot_section_t *) bh_malloc(sizeof(aot_section_t)))) {
|
||||
if (!(cur_section = (aot_section_t *) APP_MGR_MALLOC(sizeof(aot_section_t)))) {
|
||||
app_manager_printf("Allocate memory failed!\n");
|
||||
goto fail;
|
||||
}
|
||||
@ -1377,7 +1371,7 @@ wasm_app_module_on_install_request_byte_arrive(uint8 ch,
|
||||
}
|
||||
else {
|
||||
if (!(section->section_body =
|
||||
bh_malloc(section->section_body_size))) {
|
||||
APP_MGR_MALLOC(section->section_body_size))) {
|
||||
app_manager_printf("Allocate memory failed!\n");
|
||||
goto fail;
|
||||
}
|
||||
@ -1411,7 +1405,7 @@ wasm_app_module_on_install_request_byte_arrive(uint8 ch,
|
||||
if (recv_ctx.total_received_size == request_total_size) {
|
||||
/* whole aot file received */
|
||||
if (module_wasm_app_handle_install_msg(&recv_ctx.message)) {
|
||||
bh_free(recv_ctx.message.request_url);
|
||||
APP_MGR_FREE(recv_ctx.message.request_url);
|
||||
recv_ctx.message.request_url = NULL;
|
||||
memset(&recv_ctx, 0, sizeof(recv_ctx));
|
||||
return true;
|
||||
@ -1449,7 +1443,7 @@ fail:
|
||||
}
|
||||
|
||||
if (recv_ctx.message.request_url != NULL) {
|
||||
bh_free(recv_ctx.message.request_url);
|
||||
APP_MGR_FREE(recv_ctx.message.request_url);
|
||||
recv_ctx.message.request_url = NULL;
|
||||
}
|
||||
|
||||
@ -1466,7 +1460,7 @@ module_wasm_app_handle_install_msg(install_wasm_app_msg_t *message)
|
||||
request_t *request = NULL;
|
||||
bh_message_t msg;
|
||||
|
||||
request = (request_t *) bh_malloc(sizeof(request_t));
|
||||
request = (request_t *) APP_MGR_MALLOC(sizeof(request_t));
|
||||
if (request == NULL)
|
||||
return false;
|
||||
|
||||
@ -1477,7 +1471,7 @@ module_wasm_app_handle_install_msg(install_wasm_app_msg_t *message)
|
||||
request->sender = ID_HOST;
|
||||
request->mid = message->request_mid;
|
||||
request->payload_len = sizeof(message->app_file);
|
||||
request->payload = bh_malloc(request->payload_len);
|
||||
request->payload = APP_MGR_MALLOC(request->payload_len);
|
||||
|
||||
if (request->url == NULL || request->payload == NULL) {
|
||||
request_cleaner(request);
|
||||
@ -1512,8 +1506,8 @@ destroy_all_wasm_sections(wasm_section_list_t sections)
|
||||
while (cur) {
|
||||
wasm_section_t *next = cur->next;
|
||||
if (cur->section_body != NULL)
|
||||
bh_free(cur->section_body);
|
||||
bh_free(cur);
|
||||
APP_MGR_FREE(cur->section_body);
|
||||
APP_MGR_FREE(cur);
|
||||
cur = next;
|
||||
}
|
||||
}
|
||||
@ -1537,8 +1531,8 @@ destroy_part_wasm_sections(wasm_section_list_t *p_sections,
|
||||
*p_sections = next;
|
||||
|
||||
if (cur->section_body != NULL)
|
||||
bh_free(cur->section_body);
|
||||
bh_free(cur);
|
||||
APP_MGR_FREE(cur->section_body);
|
||||
APP_MGR_FREE(cur);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
@ -1561,9 +1555,9 @@ destroy_all_aot_sections(aot_section_list_t sections)
|
||||
if (cur->section_type == AOT_SECTION_TYPE_TEXT)
|
||||
bh_munmap(cur->section_body, cur->section_body_size);
|
||||
else
|
||||
bh_free(cur->section_body);
|
||||
APP_MGR_FREE(cur->section_body);
|
||||
}
|
||||
bh_free(cur);
|
||||
APP_MGR_FREE(cur);
|
||||
cur = next;
|
||||
}
|
||||
}
|
||||
@ -1591,9 +1585,9 @@ destroy_part_aot_sections(aot_section_list_t *p_sections,
|
||||
if (cur->section_type == AOT_SECTION_TYPE_TEXT)
|
||||
bh_munmap(cur->section_body, cur->section_body_size);
|
||||
else
|
||||
bh_free(cur->section_body);
|
||||
APP_MGR_FREE(cur->section_body);
|
||||
}
|
||||
bh_free(cur);
|
||||
APP_MGR_FREE(cur);
|
||||
break;
|
||||
}
|
||||
else {
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
|
||||
#include "app_manager.h"
|
||||
#include "bh_platform.h"
|
||||
#include "bh_memory.h"
|
||||
#include <autoconf.h>
|
||||
#include <zephyr.h>
|
||||
#include <kernel.h>
|
||||
@ -21,7 +20,7 @@ void*
|
||||
app_manager_timer_create(void (*timer_callback)(void*),
|
||||
watchdog_timer *wd_timer)
|
||||
{
|
||||
struct k_timer_watchdog *timer = bh_malloc(sizeof(struct k_timer_watchdog));
|
||||
struct k_timer_watchdog *timer = APP_MGR_MALLOC(sizeof(struct k_timer_watchdog));
|
||||
|
||||
if (timer) {
|
||||
k_timer_init(&timer->timer, (void (*)(struct k_timer*)) timer_callback,
|
||||
@ -34,7 +33,7 @@ app_manager_timer_create(void (*timer_callback)(void*),
|
||||
|
||||
void app_manager_timer_destroy(void *timer)
|
||||
{
|
||||
bh_free(timer);
|
||||
APP_MGR_FREE(timer);
|
||||
}
|
||||
|
||||
void app_manager_timer_start(void *timer, int timeout)
|
||||
|
||||
@ -158,14 +158,14 @@ bool am_register_resource(const char *url,
|
||||
if (register_num >= RESOURCE_REGISTRATION_NUM_MAX)
|
||||
return false;
|
||||
|
||||
r = (app_res_register_t *) bh_malloc(sizeof(app_res_register_t));
|
||||
r = (app_res_register_t *) APP_MGR_MALLOC(sizeof(app_res_register_t));
|
||||
if (r == NULL)
|
||||
return false;
|
||||
|
||||
memset(r, 0, sizeof(*r));
|
||||
r->url = bh_strdup(url);
|
||||
if (r->url == NULL) {
|
||||
bh_free(r);
|
||||
APP_MGR_FREE(r);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -191,8 +191,8 @@ void am_cleanup_registeration(uint32 register_id)
|
||||
else
|
||||
g_resources = next;
|
||||
|
||||
bh_free(r->url);
|
||||
bh_free(r);
|
||||
APP_MGR_FREE(r->url);
|
||||
APP_MGR_FREE(r);
|
||||
} else
|
||||
/* if r is freed, should not change prev. Only set prev to r
|
||||
when r isn't freed. */
|
||||
|
||||
@ -6,8 +6,6 @@
|
||||
#include "watchdog.h"
|
||||
#include "bh_queue.h"
|
||||
#include "bh_thread.h"
|
||||
#include "bh_memory.h"
|
||||
#include "jeff_export.h"
|
||||
|
||||
#define WATCHDOG_THREAD_PRIORITY 5
|
||||
|
||||
|
||||
Reference in New Issue
Block a user