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:
parent
d894c07bb8
commit
fb9ccbf88e
|
@ -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 *
|
||||
|
|
13
src/psl.c
13
src/psl.c
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
13
src/psl2c.c
13
src/psl2c.c
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ static void test_psl(void)
|
|||
failed++;
|
||||
}
|
||||
|
||||
psl_free(&psl);
|
||||
psl_free(psl);
|
||||
}
|
||||
|
||||
int main(int argc, const char * const *argv)
|
||||
|
|
|
@ -86,7 +86,7 @@ static void test_psl(void)
|
|||
}
|
||||
}
|
||||
|
||||
psl_free(&psl);
|
||||
psl_free(psl);
|
||||
}
|
||||
|
||||
int main(int argc, const char * const *argv)
|
||||
|
|
Loading…
Reference in New Issue