From: Sebastian B. <sb...@us...> - 2014-01-19 18:43:09
|
Update of /cvsroot/simplemail/simplemail In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv23883 Modified Files: index_external.c Log Message: Refactored the comparision of the bnode string with a given string into an own function. Index: index_external.c =================================================================== RCS file: /cvsroot/simplemail/simplemail/index_external.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- index_external.c 19 Jan 2014 18:42:21 -0000 1.29 +++ index_external.c 19 Jan 2014 18:43:07 -0000 1.30 @@ -196,6 +196,26 @@ return str; } +/** + * Compares contents represented by the given element with the given text. If str is the contents, + * then the function places the return value of strcmp(str, text) into *out_cmp. + * + * @param idx + * @param e + * @param text + * @param out_cmp + * @return 0 on failure, 1 on success. + */ +static int bnode_compare_string(struct index_external *idx, struct bnode_element *e, const char *text, int *out_cmp) +{ + char *str = bnode_read_string(idx, e); + if (!str) return 0; + + *out_cmp = strcmp(str, text); + free(str); + return 1; +} + #define BNODE_PATH_MAX_NODES 24 /** @@ -241,11 +261,8 @@ { int cmp; struct bnode_element *e = bnode_get_ith_element_of_node(idx, tmp, i); - char *str = bnode_read_string(idx, e); - if (!str) return 0; - - cmp = strcmp(str, text); - free(str); + if (!bnode_compare_string(idx, e, text, &cmp)) + return 0; if (!cmp) { |