>From bdc07e1841a59df8096e4b77220ff1b299451d85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Fri, 17 Dec 2010 00:08:39 +0100 Subject: [PATCH 3/3] Remove pointless check before free --- src/formatter.c | 30 ++++++++++-------------------- 1 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/formatter.c b/src/formatter.c index 04a14fd..0a7f0d9 100644 --- a/src/formatter.c +++ b/src/formatter.c @@ -454,8 +454,7 @@ fsdp_set_information(fsdp_description_t *dsc, const char *info) if ( (NULL == dsc) || (NULL == info) ) return FSDPE_INVALID_PARAMETER; - if ( NULL != dsc->i_information ) - free(dsc->i_information); + free(dsc->i_information); dsc->i_information = strdup(info); return FSDPE_OK; } @@ -466,8 +465,7 @@ fsdp_set_uri(fsdp_description_t *dsc, const char *uri) if ( (NULL == dsc) || (NULL == uri) ) return FSDPE_INVALID_PARAMETER; - if ( NULL != dsc->u_uri ) - free(dsc->u_uri); + free(dsc->u_uri); dsc->u_uri = strdup(uri); return FSDPE_OK; } @@ -514,8 +512,7 @@ fsdp_set_conn_address(fsdp_description_t *dsc, fsdp_network_type_t nt, } dsc->c_network_type = nt; dsc->c_address_type = at; - if ( NULL != dsc->c_address.address ) - free(dsc->c_address.address); + free(dsc->c_address.address); dsc->c_address.address = strdup(address); dsc->c_address.address_ttl = address_ttl; dsc->c_address.address_count = address_count; @@ -607,8 +604,7 @@ fsdp_set_encryption(fsdp_description_t *dsc, fsdp_encryption_method_t emethod, return FSDPE_INVALID_PARAMETER; } dsc->k_encryption_method = emethod; - if ( NULL != dsc->k_encryption_content ) - free(dsc->k_encryption_content); + free(dsc->k_encryption_content); if ( FSDP_ENCRYPTION_METHOD_PROMPT != emethod ) dsc->k_encryption_content = strdup(ekey); return FSDPE_OK; @@ -619,8 +615,7 @@ fsdp_set_timezone_adj(fsdp_description_t *dsc, const char *adj) { if ( (NULL == dsc) || (NULL == adj) ) return FSDPE_INVALID_PARAMETER; - if ( NULL != dsc->timezone_adj ) - free(dsc->timezone_adj); + free(dsc->timezone_adj); dsc->timezone_adj = strdup(adj); return FSDPE_OK; } @@ -632,8 +627,7 @@ fsdp_set_str_att(fsdp_description_t *dsc, fsdp_session_str_att_t att, if ( NULL == dsc ) return FSDPE_INVALID_PARAMETER; if ( att <= FSDP_LAST_SESSION_STR_ATT ) { - if ( NULL != dsc->a_str_attributes[att] ) - free(dsc->a_str_attributes[att]); + free(dsc->a_str_attributes[att]); dsc->a_str_attributes[att] = strdup(value); } else return FSDPE_INVALID_PARAMETER; @@ -778,8 +772,7 @@ fsdp_set_media_title(fsdp_media_description_t *mdsc, const char *title) if ( (NULL == mdsc) || (NULL == title) ) { return FSDPE_INVALID_PARAMETER; } - if ( NULL != mdsc->i_title ) - free(mdsc->i_title); + free(mdsc->i_title); mdsc->i_title = strdup(title); return FSDPE_OK; } @@ -795,8 +788,7 @@ fsdp_set_media_conn_address(fsdp_media_description_t *mdsc, } mdsc->c_network_type = nt; mdsc->c_address_type = at; - if ( NULL != mdsc->c_address.address ) - free(mdsc->c_address.address); + free(mdsc->c_address.address); mdsc->c_address.address = strdup(address); mdsc->c_address.address_ttl = address_ttl; mdsc->c_address.address_count = address_count; @@ -838,8 +830,7 @@ fsdp_set_media_encryption(fsdp_media_description_t *mdsc, return FSDPE_INVALID_PARAMETER; } mdsc->k_encryption_method = emethod; - if ( NULL != mdsc->k_encryption_content ) - free(mdsc->k_encryption_content); + free(mdsc->k_encryption_content); if ( FSDP_ENCRYPTION_METHOD_PROMPT != emethod ) mdsc->k_encryption_content = strdup(ekey); return FSDPE_OK; @@ -990,8 +981,7 @@ fsdp_set_media_rtcp(fsdp_media_description_t *mdsc, unsigned int port, mdsc->a_rtcp_port = port; mdsc->a_rtcp_network_type = nt; mdsc->a_rtcp_address_type = at; - if ( NULL != mdsc->a_rtcp_address ) - free(mdsc->a_rtcp_address); + free(mdsc->a_rtcp_address); mdsc->a_rtcp_address = strdup(address); return FSDPE_OK; } -- 1.7.3.3