* @param[in] argv The argument vector
* @param[in] callback The set of callback functions to handle application lifecycle events
* @param[in] user_data The user data to be passed to the callback functions
- * @param[in] handle The handle of appcore context
+ * @param[out] handle The appcore_context handle to be newly created on success
*
* @return 0 on success, otherwise a negative error value
* @retval #APP_ERROR_NONE Successful
return app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "failed to get the package's app name");
}
- app_context->callback = callback;
+ app_context->callback = (ui_app_lifecycle_callback_s *)malloc(sizeof(ui_app_lifecycle_callback_s));
+ if (app_context->callback == NULL) {
+ free(app_context->app_name);
+ free(app_context->package);
+ free(app_context);
+ return app_error(APP_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+ }
+ memcpy(app_context->callback, callback, sizeof(ui_app_lifecycle_callback_s));
+
app_context->data = user_data;
*handle = app_context;
if (handle == NULL)
return;
+ if (handle->callback) {
+ free(handle->callback);
+ handle->callback = NULL;
+ }
+
if (handle->app_name) {
free(handle->app_name);
handle->app_name = NULL;