Fix *_ctx_new and *_ctx_free implementations
They both will only alloc and free the internal *_ctx structs. Get rid of the void * argument for new and only pass arg to *_free instead of the whole lc_*_ctx struct.
This commit is contained in:
parent
0a47025c19
commit
f511cddf0d
6 changed files with 17 additions and 18 deletions
13
cipher.c
13
cipher.c
|
@ -87,7 +87,7 @@ lc_cipher_ctx_new(const struct lc_cipher_impl *impl)
|
|||
if (ctx == NULL)
|
||||
return NULL;
|
||||
if (impl->ctx_new != NULL) {
|
||||
ctx->arg = impl->ctx_new(NULL);
|
||||
ctx->arg = impl->ctx_new();
|
||||
if (ctx->arg == NULL) {
|
||||
free(ctx);
|
||||
return NULL;
|
||||
|
@ -102,11 +102,10 @@ lc_cipher_ctx_new(const struct lc_cipher_impl *impl)
|
|||
void
|
||||
lc_cipher_ctx_free(struct lc_cipher_ctx *ctx)
|
||||
{
|
||||
if (ctx != NULL && ctx->impl != NULL && ctx->impl->ctx_free != NULL)
|
||||
ctx->impl->ctx_free(ctx);
|
||||
else {
|
||||
if (ctx != NULL)
|
||||
free(ctx->arg);
|
||||
free(ctx);
|
||||
if (ctx != NULL) {
|
||||
if (ctx->impl != NULL && ctx->impl->ctx_free != NULL)
|
||||
ctx->impl->ctx_free(ctx->arg);
|
||||
free(ctx->arg);
|
||||
}
|
||||
free(ctx);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue