changeset 23:4a3bc3a7afbe

refactoring: early exit instead of deep if levels
author meillo@marmaro.de
date Fri, 05 Dec 2008 11:32:26 +0100 (2008-12-05)
parents 7c1635972aa7
children 31cf4655ab0c
files src/address.c
diffstat 1 files changed, 22 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/src/address.c	Fri Dec 05 11:26:24 2008 +0100
+++ b/src/address.c	Fri Dec 05 11:32:26 2008 +0100
@@ -35,11 +35,10 @@
 create_address_qualified(gchar * path, gboolean is_rfc821, gchar * domain)
 {
 	address *addr = create_address(path, is_rfc821);
-	if (addr != NULL) {
-		if (addr->domain == NULL)
+
+	if (addr != NULL && addr->domain == NULL) {
 			addr->domain = g_strdup(domain);
 	}
-
 	return addr;
 }
 
@@ -76,26 +75,29 @@
 {
 	address *addr = NULL;
 
-	if (orig) {
-		addr = g_malloc(sizeof(address));
-		if (addr) {
-			addr->address = g_strdup(orig->address);
+	if (!orig) {
+		return NULL;
+	}
 
-			if (l_part == NULL)
-				addr->local_part = g_strdup(orig->local_part);
-			else
-				addr->local_part = g_strdup(l_part);
+	if ((addr = g_malloc(sizeof(address))) == NULL) {
+		return NULL;
+	}
+
+	addr->address = g_strdup(orig->address);
 
-			if (dom == NULL)
-				addr->domain = g_strdup(orig->domain);
-			else
-				addr->domain = g_strdup(dom);
+	if (l_part == NULL)
+		addr->local_part = g_strdup(orig->local_part);
+	else
+		addr->local_part = g_strdup(l_part);
 
-			addr->flags = 0;
-			addr->children = NULL;
-			addr->parent = NULL;
-		}
-	}
+	if (dom == NULL)
+		addr->domain = g_strdup(orig->domain);
+	else
+		addr->domain = g_strdup(dom);
+
+	addr->flags = 0;
+	addr->children = NULL;
+	addr->parent = NULL;
 	return addr;
 }