change psl_free() to take a psl_ctx_t *psl

This uses the more common convention where the variable freed is the
thing returned from the constructor directly, rather than having the
deallocator also zero out the pointer itself.
This commit is contained in:
Daniel Kahn Gillmor 2014-03-27 13:16:54 -04:00 committed by Tim Ruehsen
parent d894c07bb8
commit fb9ccbf88e
5 changed files with 14 additions and 18 deletions

View File

@ -55,7 +55,7 @@ PSL_BEGIN_DECLS
typedef struct _psl_ctx_st psl_ctx_t;
void
psl_free(psl_ctx_t **psl);
psl_free(psl_ctx_t *psl);
psl_ctx_t *
psl_load_file(const char *fname);
psl_ctx_t *

View File

@ -421,15 +421,12 @@ const psl_ctx_t *psl_builtin(void)
return &_builtin_psl;
}
void psl_free(psl_ctx_t **psl)
void psl_free(psl_ctx_t *psl)
{
if (psl && *psl) {
if (*psl != &_builtin_psl) {
_vector_free(&(*psl)->suffixes);
_vector_free(&(*psl)->suffix_exceptions);
}
free(*psl);
*psl = NULL;
if (psl && psl != &_builtin_psl) {
_vector_free(&psl->suffixes);
_vector_free(&psl->suffix_exceptions);
free(psl);
}
}

View File

@ -279,13 +279,12 @@ static void _print_psl_entries(FILE *fpout, const _psl_vector_t *v, const char *
fprintf(fpout, "};\n");
}
void psl_free(psl_ctx_t **psl)
void psl_free(psl_ctx_t *psl)
{
if (psl && *psl) {
_vector_free(&(*psl)->suffixes);
_vector_free(&(*psl)->suffix_exceptions);
free(*psl);
*psl = NULL;
if (psl) {
_vector_free(&psl->suffixes);
_vector_free(&psl->suffix_exceptions);
free(psl);
}
}
@ -389,6 +388,6 @@ int main(int argc, const char **argv)
ret = 3;
}
psl_free(&psl);
psl_free(psl);
return ret;
}

View File

@ -111,7 +111,7 @@ static void test_psl(void)
failed++;
}
psl_free(&psl);
psl_free(psl);
}
int main(int argc, const char * const *argv)

View File

@ -86,7 +86,7 @@ static void test_psl(void)
}
}
psl_free(&psl);
psl_free(psl);
}
int main(int argc, const char * const *argv)