Copy and keep lifecycle callback in appcore 83/74783/3 accepted/tizen/common/20160616.151745 accepted/tizen/ivi/20160616.105028 accepted/tizen/mobile/20160616.104946 accepted/tizen/tv/20160616.104957 accepted/tizen/wearable/20160616.105013 submit/tizen/20160616.003540
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 15 Jun 2016 12:35:39 +0000 (21:35 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 15 Jun 2016 23:07:56 +0000 (08:07 +0900)
Change-Id: Ic6d0759d21cbc47d97fc9f5d6e0f8f7078b42b5f
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/app_internal.h
src/app_main.c

index d2ccb7b..bdd09fe 100644 (file)
@@ -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
index 2378e8a..ccc1bd8 100644 (file)
@@ -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;