Fix pkg updateinfo 16/139016/4
authorJunghyun Yeon <jungh.yeon@samsung.com>
Mon, 17 Jul 2017 02:21:10 +0000 (11:21 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 18 Jul 2017 00:01:00 +0000 (00:01 +0000)
- Remove false initialization
- Add NULL initialization at gslist
- Change adding new updateinof into list from append to prepend
  for performance

Change-Id: I7823fb892646b5b32118943ae271c7f6abb871a8
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
src/pkgmgrinfo_updateinfo.c

index a2d210f..96f2351 100644 (file)
@@ -264,7 +264,8 @@ static int _get_pkg_updateinfo_from_db(const char *pkgid,
                        return -1;
                }
                update_info->type = convert_type;
-               *update_info_list = g_slist_append(*update_info_list, update_info);
+               *update_info_list = g_slist_prepend(*update_info_list,
+                               update_info);
        }
 
        free(dbpath);
@@ -319,18 +320,12 @@ API int pkgmgrinfo_updateinfo_usr_foreach_updateinfo(uid_t uid,
                pkgmgrinfo_foreach_updateinfo_cb callback, void *user_data)
 {
        int ret;
-       GSList *info_list;
+       GSList *info_list = NULL;
        GSList *tmp_list;
 
        if (callback == NULL)
                return PMINFO_R_EINVAL;
 
-       info_list = calloc(1, sizeof(updateinfo_x));
-       if (info_list == NULL) {
-               _LOGE("Out of memory");
-               return PMINFO_R_ERROR;
-       }
-
        ret = _get_pkg_updateinfo_from_db(NULL, &info_list, uid);
        if (ret != 0) {
                _LOGE("Failed to get pkg update info for user[%d]", (int)uid);