From: Hwankyu Jhun Date: Wed, 15 Jun 2016 12:35:39 +0000 (+0900) Subject: Copy and keep lifecycle callback in appcore X-Git-Tag: submit/tizen/20170725.231500~6^2~56 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5d4ef56db970718cd0181cd9f17dfb601543d660;p=platform%2Fcore%2Fapi%2Fpreference.git Copy and keep lifecycle callback in appcore Change-Id: Ic6d0759d21cbc47d97fc9f5d6e0f8f7078b42b5f Signed-off-by: Hwankyu Jhun --- diff --git a/include/app_internal.h b/include/app_internal.h index d2ccb7b..bdd09fe 100644 --- a/include/app_internal.h +++ b/include/app_internal.h @@ -268,7 +268,7 @@ void app_efl_exit(void); * @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 diff --git a/src/app_main.c b/src/app_main.c index 2378e8a..ccc1bd8 100644 --- a/src/app_main.c +++ b/src/app_main.c @@ -698,7 +698,15 @@ static int __create_ui_app_context(ui_app_lifecycle_callback_s *callback, void * 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; @@ -711,6 +719,11 @@ static void __destroy_ui_app_context(struct ui_app_context *handle) 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;