lib

morphux C utility library
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/lib

commit 8a5017929c3eff489fb6c397bfc0e3c4a988f16d
parent cdbc87380c5f01b64fd535edb396e8dd9da64ab2
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Fri, 16 Jun 2017 12:18:07 +0200

Fix(Vector_string): Does not longer throw an error when a paramter is NULL

Diffstat:
Msrc/m_list.c | 18+++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/m_list.c b/src/m_list.c @@ -251,21 +251,25 @@ vector_string_t *vector_string_init(const char *str1, const char *str2) { ret->str2 = NULL; if (str1 != NULL) + { ret->str1 = strdup(str1); + if (ret->str1 == NULL) + goto cleanup; + } + if (str2 != NULL) + { ret->str2 = strdup(str2); - - if (ret->str1 == NULL || ret->str2 == NULL) - goto cleanup; + if (ret->str2 == NULL) + goto cleanup; + } return ret; cleanup: - if (ret->str1 != NULL) - free(ret->str1); - if (ret->str2 != NULL) - free(ret->str2); + free(ret->str1); + free(ret->str2); free(ret); return NULL; }