]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/comp/comp_lib.c
Accept NULL in *_free.
[thirdparty/openssl.git] / crypto / comp / comp_lib.c
CommitLineData
dfeab068
RE
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include "objects.h"
5#include "comp.h"
6
7COMP_CTX *COMP_CTX_new(meth)
8COMP_METHOD *meth;
9 {
10 COMP_CTX *ret;
11
12 if ((ret=(COMP_CTX *)Malloc(sizeof(COMP_CTX))) == NULL)
13 {
14 /* ZZZZZZZZZZZZZZZZ */
15 return(NULL);
16 }
17 memset(ret,0,sizeof(COMP_CTX));
18 ret->meth=meth;
19 if ((ret->meth->init != NULL) && !ret->meth->init(ret))
20 {
21 Free(ret);
22 ret=NULL;
23 }
24#if 0
25 else
26 CRYPTO_new_ex_data(rsa_meth,(char *)ret,&ret->ex_data);
27#endif
28 return(ret);
29 }
30
31void COMP_CTX_free(ctx)
32COMP_CTX *ctx;
33 {
34 /* CRYPTO_free_ex_data(rsa_meth,(char *)ctx,&ctx->ex_data); */
35
e03ddfae
BL
36 if(ctx == NULL)
37 return;
38
dfeab068
RE
39 if (ctx->meth->finish != NULL)
40 ctx->meth->finish(ctx);
41
42 Free(ctx);
43 }
44
45int COMP_compress_block(ctx,out,olen,in,ilen)
46COMP_CTX *ctx;
47unsigned char *out;
48int olen;
49unsigned char *in;
50int ilen;
51 {
52 int ret;
53 if (ctx->meth->compress == NULL)
54 {
55 /* ZZZZZZZZZZZZZZZZZ */
56 return(-1);
57 }
58 ret=ctx->meth->compress(ctx,out,olen,in,ilen);
59 if (ret > 0)
60 {
61 ctx->compress_in+=ilen;
62 ctx->compress_out+=ret;
63 }
64 return(ret);
65 }
66
67int COMP_expand_block(ctx,out,olen,in,ilen)
68COMP_CTX *ctx;
69unsigned char *out;
70int olen;
71unsigned char *in;
72int ilen;
73 {
74 int ret;
75
76 if (ctx->meth->expand == NULL)
77 {
78 /* ZZZZZZZZZZZZZZZZZ */
79 return(-1);
80 }
81 ret=ctx->meth->expand(ctx,out,olen,in,ilen);
82 if (ret > 0)
83 {
84 ctx->expand_in+=ilen;
85 ctx->expand_out+=ret;
86 }
87 return(ret);
88 }