Fix memory leak issues
[platform/core/telephony/tel-plugin-packetservice.git] / src / ps_context.c
index 846e3f3..1b9a134 100644 (file)
@@ -460,11 +460,6 @@ static gboolean __ps_context_create_co_context(gpointer object, GHashTable *prop
 
        context = (ps_context_t *)object;
        co_context = tcore_context_new(context->plg, path, NULL);
-#ifdef TIZEN_PS_IPV4_ONLY
-       dbg("pdp type has been changed (%d)", CONTEXT_TYPE_IP);
-       pdp_type = CONTEXT_TYPE_IP;
-       roam_pdp_type = CONTEXT_TYPE_IP;
-#endif
        tcore_context_set_type(co_context, pdp_type);
        tcore_context_set_roam_pdp_type(co_context, roam_pdp_type);
        tcore_context_set_state(co_context, CONTEXT_STATE_DEACTIVATED);
@@ -789,7 +784,7 @@ static int __ps_context_insert_network_id_to_database(gchar *mccmnc, gchar *cp_n
         * if NONE exists, then 'Network ID' would be equal to 1
         * else if there exists a valid maximum entry; 'Network ID' would be incremented value.
         */
-       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
                                (GDestroyNotify) g_hash_table_destroy);
 
        /* SQL query */
@@ -937,20 +932,18 @@ static int __ps_context_insert_profile_to_database(GHashTable *property, int net
        /* Initialize parameters */
        in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
 
-       g_hash_table_insert(in_param, "1",
-                       g_strdup_printf("%d", profile_id));                     /* Profile ID */
-       g_hash_table_insert(in_param, "2", profile_name);       /* Profile Name */
-       g_hash_table_insert(in_param, "3", apn);                        /* APN */
-       g_hash_table_insert(in_param, "4", auth_type);          /* Auth Type */
-       g_hash_table_insert(in_param, "5", auth_id);            /* Auth ID */
-       g_hash_table_insert(in_param, "6", auth_pwd);           /* Auth Password */
-       g_hash_table_insert(in_param, "7", pdp_protocol);               /* PDP Protocol */
-       g_hash_table_insert(in_param, "8", roam_pdp_protocol);          /* Roam PDP Protocol */
-       g_hash_table_insert(in_param, "9", proxy_addr);         /* Proxy Address */
-       g_hash_table_insert(in_param, "10", home_url);          /* Home URL */
-       g_hash_table_insert(in_param, "11",
-                       g_strdup_printf("%d", network_id));                     /* Network ID */
-       g_hash_table_insert(in_param, "12", svc_id);            /* Service ID */
+       g_hash_table_insert(in_param, "1", g_strdup_printf("%d", profile_id));  /* Profile ID */
+       g_hash_table_insert(in_param, "2", g_strdup(profile_name));     /* Profile Name */
+       g_hash_table_insert(in_param, "3", g_strdup(apn));                      /* APN */
+       g_hash_table_insert(in_param, "4", g_strdup(auth_type));        /* Auth Type */
+       g_hash_table_insert(in_param, "5", g_strdup(auth_id));          /* Auth ID */
+       g_hash_table_insert(in_param, "6", g_strdup(auth_pwd));         /* Auth Password */
+       g_hash_table_insert(in_param, "7", g_strdup(pdp_protocol));     /* PDP Protocol */
+       g_hash_table_insert(in_param, "8", g_strdup(roam_pdp_protocol));        /* Roam PDP Protocol */
+       g_hash_table_insert(in_param, "9", g_strdup(proxy_addr));               /* Proxy Address */
+       g_hash_table_insert(in_param, "10", g_strdup(home_url));                /* Home URL */
+       g_hash_table_insert(in_param, "11", g_strdup_printf("%d", network_id));         /* Network ID */
+       g_hash_table_insert(in_param, "12", g_strdup(svc_id));          /* Service ID */
 
        info("[%s] Profile ID: [%d] Profile name: [%s] APN :[%s] Auth Type [%s] Auth ID: [%s] "
                "Auth Password: [%s] PDP Protocol: [%s] Roam PDP Protocol: [%s] Proxy Address: [%s] Home URL: [%s] Service ID: [%s]",
@@ -975,8 +968,17 @@ static int __ps_context_insert_profile_to_database(GHashTable *property, int net
        }
 
        /* Free resources */
+       g_free(profile_name);
+       g_free(apn);
+       g_free(auth_type);
+       g_free(auth_id);
+       g_free(auth_pwd);
+       g_free(proxy_addr);
+       g_free(home_url);
+       g_free(svc_id);
+       g_free(pdp_protocol);
+       g_free(roam_pdp_protocol);
        g_hash_table_destroy(in_param);
-
 EXIT:
        /* De-initialize Storage */
        tcore_storage_remove_handle(strg_db, handle);
@@ -1010,7 +1012,7 @@ static int __ps_context_load_network_id_from_database(gchar *mccmnc, gchar *cp_n
        in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
        g_hash_table_insert(in_param, "1", g_strdup(mccmnc));
 
-       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
                        (GDestroyNotify) g_hash_table_destroy);
 
        /* SQL Query */
@@ -1078,7 +1080,7 @@ static gchar *__ps_context_load_network_name_from_database(int network_id, gchar
        in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
        g_hash_table_insert(in_param, "1", g_strdup_printf("%d", network_id));
 
-       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
                                                (GDestroyNotify)g_hash_table_destroy);
 
        /* SQL query */
@@ -1141,7 +1143,7 @@ static int __ps_context_load_profile_id_from_database(gchar *cp_name)
        }
 
        /* Initialize parameters */
-       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
                        (GDestroyNotify) g_hash_table_destroy);
 
        /* SQL query */
@@ -1208,7 +1210,7 @@ static int __ps_context_load_num_of_pdn_from_database(gchar *mccmnc, gchar *cp_n
        in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
        g_hash_table_insert(in_param, "1", g_strdup(mccmnc));
 
-       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
                        (GDestroyNotify) g_hash_table_destroy);
 
        /* SQL query */
@@ -1732,7 +1734,7 @@ static gpointer __ps_context_add_context(gpointer modem, gchar *mccmnc, int prof
        in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
        g_hash_table_insert(in_param, "1", g_strdup_printf("%d", profile_id));
 
-       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
                        (GDestroyNotify) g_hash_table_destroy);
 
        /* SQL query */
@@ -1804,7 +1806,7 @@ gboolean _ps_context_check_is_roaming_apn_support(gchar* mccmnc, gchar* cp_name)
        in_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
        g_hash_table_insert(in_param, "1", g_strdup_printf("%d", network_info_id));
 
-       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+       out_param = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
                        (GDestroyNotify) g_hash_table_destroy);
 
        /* SQL query */