samiparse: change log level for debugging
authorEunhae Choi <eunhae1.choi@samsung.com>
Tue, 18 Sep 2018 06:14:47 +0000 (15:14 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Tue, 18 Sep 2018 06:14:49 +0000 (15:14 +0900)
- change some log level to warning
- change mem alloc and free function to glib one

Change-Id: I14d22faa9c5a51f0abf8c20f4eba99e422a98f97

gst/subparse/samiparse.c

index 1e2ec5c..50c26e8 100644 (file)
@@ -632,7 +632,7 @@ html_context_handle_element (HtmlContext * ctxt,
       if (!next)
         break;
 
-      attr_value = (gchar*)malloc (3);
+      attr_value = (gchar*)g_malloc0 (3);
       next = next + 5;
       /* skip spaces */
       while (*next == ' ')
@@ -649,7 +649,7 @@ html_context_handle_element (HtmlContext * ctxt,
             name_temp--;
 
             if (*name_temp == '.') {
-              attr_name = (gchar*) malloc (character_count + 1);
+              attr_name = (gchar*) g_malloc0 (character_count + 1);
               break;
             }
             else if (*name_temp != ' ')
@@ -913,10 +913,11 @@ handle_p (GstSamiContext * sctx, const gchar ** atts)
           && (sctx->time1 == sctx->time2))
         sctx->language_changed = TRUE;
       else if (!sctx->current_language)
-        sctx->current_language = (gchar*) malloc (str_size);
+        sctx->current_language = (gchar*) g_malloc0 (str_size);
 
       if (key && !g_ascii_strcasecmp ("class", key) && value) {
         strncpy (sctx->current_language, value, str_size - 1);
+
         if (sctx->desired_language == NULL) {
           sctx->desired_language = g_strdup(value);
           GST_LOG("no language list was found and desired lang was set to %s", sctx->desired_language);
@@ -959,16 +960,17 @@ handle_start_language_list (GstSamiContext * sctx, const gchar ** atts)
         continue;
 
       new = g_new0 (GstLangStruct, 1);
-      new->language_code = (gchar*) malloc (strlen(value) + 1);
+      new->language_code = (gchar*) g_malloc0 (strlen(value) + 1);
       if (new->language_code && value)
         g_strlcpy (new->language_code, value, strlen(value) + 1);
-      new->language_key = (gchar*) malloc (strlen(key) + 1);
+      new->language_key = (gchar*) g_malloc0 (strlen(key) + 1);
       if (new->language_key && key)
         g_strlcpy (new->language_key, key, strlen(key) + 1);
       sctx->lang_list = g_list_append (sctx->lang_list, new);
       temp = g_list_nth_data (sctx->lang_list, i);
       if (sctx->desired_language == NULL && key){
         sctx->desired_language = g_strdup(key);
+        GST_WARNING("set desired lang %s", sctx->desired_language);
       }
 
       if (temp)
@@ -1112,11 +1114,10 @@ sami_context_init (ParserState * state)
   context->resultbuf = g_string_new ("");
   context->state = g_string_new ("");
 #ifdef TIZEN_FEATURE_SUBPARSE_MODIFICATION
-  if (context->current_language)
-    free(context->current_language);
+  g_free(context->current_language);
   context->current_language = NULL;
-  if (context->desired_language)
-    free(context->desired_language);
+
+  g_free(context->desired_language);
   context->desired_language = NULL;
 
   if (context->lang_list) {
@@ -1124,12 +1125,12 @@ sami_context_init (ParserState * state)
     int i = 0;
 
     while ((temp = g_list_nth_data (context->lang_list, i))) {
-      if (temp->language_code)
-        free (temp->language_code);
+      g_free (temp->language_code);
       temp->language_code = NULL;
-      if (temp->language_key)
-        free (temp->language_key);
+
+      g_free (temp->language_key);
       temp->language_key = NULL;
+
       g_free (temp);
       i++;
     }
@@ -1163,12 +1164,12 @@ sami_context_deinit (ParserState * state)
 #ifdef TIZEN_FEATURE_SUBPARSE_MODIFICATION
     if (context->lang_list) {
       while ((temp = g_list_nth_data (context->lang_list, i))) {
-        if (temp->language_code)
-          free (temp->language_code);
+        g_free (temp->language_code);
         temp->language_code = NULL;
-        if (temp->language_key)
-          free (temp->language_key);
+
+        g_free (temp->language_key);
         temp->language_key = NULL;
+
         g_free (temp);
         i++;
       }
@@ -1176,12 +1177,10 @@ sami_context_deinit (ParserState * state)
     }
     context->lang_list = NULL;
 
-    if (context->current_language)
-      free (context->current_language);
+    g_free (context->current_language);
     context->current_language = NULL;
 
-    if (context->desired_language)
-      free (context->desired_language);
+    g_free (context->desired_language);
     context->desired_language = NULL;
 #endif
 
@@ -1214,12 +1213,12 @@ sami_context_change_language (ParserState * state)
   GstSamiContext *context = (GstSamiContext *) state->user_data;
   if (context->desired_language) {
     GST_LOG ("desired language was %s", context->desired_language);
-    free (context->desired_language);
+    g_free (context->desired_language);
     context->desired_language = NULL;
   }
   if(state->current_language) {
     context->desired_language = g_strdup(state->current_language);
-    GST_LOG ("desired language changed to %s", GST_STR_NULL(context->desired_language));
+    GST_WARNING ("desired language changed to %s", GST_STR_NULL(context->desired_language));
   }
 }
 #endif
@@ -1237,10 +1236,10 @@ parse_sami (ParserState * state, const gchar * line)
   if (context->lang_list)
     state->language_list = context->lang_list;
 
-  if (context->desired_language) {
-    if (state->current_language)
-      free (state->current_language);
+  if (context->desired_language && g_strcmp0(context->desired_language, state->current_language)) {
+    g_free (state->current_language);
     state->current_language = g_strdup(context->desired_language);
+    GST_WARNING("current lang is updated %s", state->current_language);
   }
 #endif
   g_free (unescaped);