[PATCH:libfontenc 2/2] Don't need to check if pointer is NULL before calling free()

Alan Coopersmith alan.coopersmith at oracle.com
Fri May 14 20:18:26 PDT 2010


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 src/encparse.c |   12 +++++-------
 src/fontenc.c  |    9 +++------
 2 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/src/encparse.c b/src/encparse.c
index 33e0a05..5b4cefb 100644
--- a/src/encparse.c
+++ b/src/encparse.c
@@ -745,20 +745,19 @@ error:
     if(encsize) free(enc); encsize=0;
     if(namsize) {
         for(i = first; i <= last; i++)
-            if(nam[i])
-                free(nam[i]);
+            free(nam[i]);
         free(nam);
         namsize = 0;
     }
     if(mapping) {
-        if(mapping->client_data) free(mapping->client_data);
+        free(mapping->client_data);
         free(mapping);
     }
     if(encoding) {
 	FontMapPtr nextmap;
-	if (encoding->name) free(encoding->name);
+	free(encoding->name);
 	for (mapping = encoding->mappings; mapping; mapping = nextmap) {
-	    if (mapping->client_data) free(mapping->client_data);
+	    free(mapping->client_data);
 	    nextmap = mapping->next;
 	    free(mapping);
 	}
@@ -930,8 +929,7 @@ FontEncIdentify(const char *fileName)
 
     names = malloc((numaliases+2)*sizeof(char*));
     if(names == NULL) {
-        if(encoding->aliases)
-            free(encoding->aliases);
+        free(encoding->aliases);
         free(encoding);
         return NULL;
     }
diff --git a/src/fontenc.c b/src/fontenc.c
index 8718eff..86f5952 100644
--- a/src/fontenc.c
+++ b/src/fontenc.c
@@ -913,10 +913,8 @@ FontMapReverse(FontMapPtr mapping)
     return reverse;
 
   bail:
-    if(map)
-        free(map);
-    if(reverse)
-        free(reverse);
+    free(map);
+    free(reverse);
     return NULL;
 }
 
@@ -930,8 +928,7 @@ FontMapReverseFree(FontMapReversePtr delendum)
         return;
 
     for(i = 0; i < FONTENC_SEGMENTS; i++)
-        if(map[i] != NULL)
-            free(map[i]);
+	free(map[i]);
 
     free(map);
     return;
-- 
1.5.6.5



More information about the xorg-devel mailing list