comparison src/address.c @ 23:4a3bc3a7afbe

refactoring: early exit instead of deep if levels
author meillo@marmaro.de
date Fri, 05 Dec 2008 11:32:26 +0100
parents a8f3424347dc
children bc9d9cd9ee8e
comparison
equal deleted inserted replaced
22:7c1635972aa7 23:4a3bc3a7afbe
33 33
34 address* 34 address*
35 create_address_qualified(gchar * path, gboolean is_rfc821, gchar * domain) 35 create_address_qualified(gchar * path, gboolean is_rfc821, gchar * domain)
36 { 36 {
37 address *addr = create_address(path, is_rfc821); 37 address *addr = create_address(path, is_rfc821);
38 if (addr != NULL) { 38
39 if (addr->domain == NULL) 39 if (addr != NULL && addr->domain == NULL) {
40 addr->domain = g_strdup(domain); 40 addr->domain = g_strdup(domain);
41 } 41 }
42
43 return addr; 42 return addr;
44 } 43 }
45 44
46 /* nothing special about pipes here, but its only called for that purpose */ 45 /* nothing special about pipes here, but its only called for that purpose */
47 address* 46 address*
74 address* 73 address*
75 copy_modify_address(const address * orig, gchar * l_part, gchar * dom) 74 copy_modify_address(const address * orig, gchar * l_part, gchar * dom)
76 { 75 {
77 address *addr = NULL; 76 address *addr = NULL;
78 77
79 if (orig) { 78 if (!orig) {
80 addr = g_malloc(sizeof(address)); 79 return NULL;
81 if (addr) { 80 }
82 addr->address = g_strdup(orig->address); 81
83 82 if ((addr = g_malloc(sizeof(address))) == NULL) {
84 if (l_part == NULL) 83 return NULL;
85 addr->local_part = g_strdup(orig->local_part); 84 }
86 else 85
87 addr->local_part = g_strdup(l_part); 86 addr->address = g_strdup(orig->address);
88 87
89 if (dom == NULL) 88 if (l_part == NULL)
90 addr->domain = g_strdup(orig->domain); 89 addr->local_part = g_strdup(orig->local_part);
91 else 90 else
92 addr->domain = g_strdup(dom); 91 addr->local_part = g_strdup(l_part);
93 92
94 addr->flags = 0; 93 if (dom == NULL)
95 addr->children = NULL; 94 addr->domain = g_strdup(orig->domain);
96 addr->parent = NULL; 95 else
97 } 96 addr->domain = g_strdup(dom);
98 } 97
98 addr->flags = 0;
99 addr->children = NULL;
100 addr->parent = NULL;
99 return addr; 101 return addr;
100 } 102 }
101 103
102 gboolean 104 gboolean
103 addr_isequal(address * addr1, address * addr2) 105 addr_isequal(address * addr1, address * addr2)