[gnac/devel] Code cleanup



commit f7458274faf8b64754110707fbc7166369edef0e
Author: BenoÃt Dupasquier <bdupasqu src gnome org>
Date:   Sat Oct 22 20:03:24 2011 +0100

    Code cleanup

 libgnac/libgnac-converter.c             |   29 ++++-----------------
 libgnac/libgnac-debug.c                 |   34 +++++++++++-------------
 src/profiles/gnac-profiles-utils.c      |   42 +++++++++++++++++--------------
 src/profiles/gnac-profiles-xml-engine.c |    8 +++--
 4 files changed, 50 insertions(+), 63 deletions(-)
---
diff --git a/libgnac/libgnac-converter.c b/libgnac/libgnac-converter.c
index e217122..5f97c46 100644
--- a/libgnac/libgnac-converter.c
+++ b/libgnac/libgnac-converter.c
@@ -142,29 +142,12 @@ libgnac_converter_finalize(GObject *gobject)
 {
   LibgnacConverter *self = LIBGNAC_CONVERTER(gobject);
 
-  if (self->priv->profile->audio_desc) {
-    g_free(self->priv->profile->audio_desc);
-  }
-
-  if (self->priv->profile->muxer_desc) {
-    g_free(self->priv->profile->muxer_desc);
-  }
-
-  if (self->priv->profile->video_desc) {
-    g_free(self->priv->profile->video_desc);
-  }
-
-  if (self->priv->profile) {
-    g_free(self->priv->profile);
-  }
-
-  if (self->priv->extension) {
-    g_free(self->priv->extension);
-  }
-
-  if (self->priv->folder_path) {
-    g_free(self->priv->folder_path);
-  }
+  g_free(self->priv->profile->audio_desc);
+  g_free(self->priv->profile->muxer_desc);
+  g_free(self->priv->profile->video_desc);
+  g_free(self->priv->profile);
+  g_free(self->priv->extension);
+  g_free(self->priv->folder_path);
 
   libgnac_output_finalize();
 
diff --git a/libgnac/libgnac-debug.c b/libgnac/libgnac-debug.c
index d6e285d..b7a1f6c 100644
--- a/libgnac/libgnac-debug.c
+++ b/libgnac/libgnac-debug.c
@@ -42,17 +42,16 @@ libgnac_debug_real(const gchar *func,
                    const gchar *format, 
                    ...)
 {
-  if (LIBGNAC_DEBUG)
-  {
-	  va_list args;
-	  char buffer[BUFFER_SIZE];
+  if (!LIBGNAC_DEBUG) return;
 
-	  va_start(args, format);
-	  g_vsnprintf(buffer, BUFFER_SIZE, format, args);
-	  va_end(args);
+	va_list args;
+	char buffer[BUFFER_SIZE];
+
+	va_start(args, format);
+	g_vsnprintf(buffer, BUFFER_SIZE, format, args);
+	va_end(args);
 
-    g_printerr("[DEBUG] %s:%d: %s\n", file, line, buffer);
-  }
+  g_printerr("[DEBUG] %s:%d: %s\n", file, line, buffer);
 }
 
 
@@ -95,15 +94,14 @@ libgnac_warning_real(const gchar *func,
 void
 libgnac_info(const gchar *format, ...)
 {
-  if (LIBGNAC_VERBOSE)
-  {
-	  va_list args;
-	  char buffer[BUFFER_SIZE];
+  if (!LIBGNAC_VERBOSE) return;
 
-	  va_start(args, format);
-	  g_vsnprintf(buffer, BUFFER_SIZE, format, args);
-	  va_end(args);
+	va_list args;
+	char buffer[BUFFER_SIZE];
+
+	va_start(args, format);
+	g_vsnprintf(buffer, BUFFER_SIZE, format, args);
+	va_end(args);
 
-    g_print("[INFO] %s\n", buffer);
-  }
+  g_print("[INFO] %s\n", buffer);
 }
diff --git a/src/profiles/gnac-profiles-utils.c b/src/profiles/gnac-profiles-utils.c
index 78aef1e..94c5480 100755
--- a/src/profiles/gnac-profiles-utils.c
+++ b/src/profiles/gnac-profiles-utils.c
@@ -1103,31 +1103,35 @@ gnac_profiles_utils_allocate_audio_profile_generic(void)
 void
 gnac_profiles_utils_free_audio_profile_generic(AudioProfileGeneric *profile)
 {
-  g_free(profile->name);
-  g_free(profile->description);
-  g_free(profile->format_id);
-  g_free(profile->format_name);
-  g_free(profile->extension);
-  g_free(profile->pipeline);
-  g_free(profile->rate);
-  g_free(profile->channels);
-  g_free(profile);
+  if (profile) {
+    g_free(profile->name);
+    g_free(profile->description);
+    g_free(profile->format_id);
+    g_free(profile->format_name);
+    g_free(profile->extension);
+    g_free(profile->pipeline);
+    g_free(profile->rate);
+    g_free(profile->channels);
+    g_free(profile);
+  }
 }
 
 
 void
 gnac_profiles_utils_free_basic_format_info_content(BasicFormatInfo *bfi)
 {
-  g_object_unref(bfi->builder);
-  if (bfi->doc != NULL) gnac_profiles_xml_engine_free_doc_xpath(bfi->doc);
-  g_free(bfi->pipeline);
-  g_free(bfi->pipeline_encoder);
-  g_free(bfi->pipeline_multiplexers);
-  g_free(bfi->format_id);
-  g_free(bfi->format_plugin_name);
-  g_free(bfi->format_name);
-  g_free(bfi->file_extension);
-  g_free(bfi->description);
+  if (bfi) {
+    g_object_unref(bfi->builder);
+    gnac_profiles_xml_engine_free_doc_xpath(bfi->doc);
+    g_free(bfi->pipeline);
+    g_free(bfi->pipeline_encoder);
+    g_free(bfi->pipeline_multiplexers);
+    g_free(bfi->format_id);
+    g_free(bfi->format_plugin_name);
+    g_free(bfi->format_name);
+    g_free(bfi->file_extension);
+    g_free(bfi->description);
+  }
 }
 
 
diff --git a/src/profiles/gnac-profiles-xml-engine.c b/src/profiles/gnac-profiles-xml-engine.c
index 280d9d0..3ba1c44 100755
--- a/src/profiles/gnac-profiles-xml-engine.c
+++ b/src/profiles/gnac-profiles-xml-engine.c
@@ -524,9 +524,11 @@ gnac_profiles_xml_engine_save_doc(XMLDoc      *dx,
 void
 gnac_profiles_xml_engine_free_doc_xpath(XMLDoc *dx)
 {
-  xmlXPathFreeContext(dx->xpath_context); 
-  xmlFreeDoc(dx->doc); 
-  g_free(dx);
+  if (dx) {
+    xmlXPathFreeContext(dx->xpath_context);
+    xmlFreeDoc(dx->doc);
+    g_free(dx);
+  }
 }
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]