diff options
Diffstat (limited to 'src/lib/libcrypto/comp/comp_lib.c')
-rw-r--r-- | src/lib/libcrypto/comp/comp_lib.c | 91 |
1 files changed, 45 insertions, 46 deletions
diff --git a/src/lib/libcrypto/comp/comp_lib.c b/src/lib/libcrypto/comp/comp_lib.c index feb07ea881..745c802228 100644 --- a/src/lib/libcrypto/comp/comp_lib.c +++ b/src/lib/libcrypto/comp/comp_lib.c | |||
@@ -4,69 +4,68 @@ | |||
4 | #include <openssl/objects.h> | 4 | #include <openssl/objects.h> |
5 | #include <openssl/comp.h> | 5 | #include <openssl/comp.h> |
6 | 6 | ||
7 | COMP_CTX *COMP_CTX_new(COMP_METHOD *meth) | 7 | COMP_CTX * |
8 | { | 8 | COMP_CTX_new(COMP_METHOD *meth) |
9 | { | ||
9 | COMP_CTX *ret; | 10 | COMP_CTX *ret; |
10 | 11 | ||
11 | if ((ret=(COMP_CTX *)malloc(sizeof(COMP_CTX))) == NULL) | 12 | if ((ret = (COMP_CTX *)malloc(sizeof(COMP_CTX))) == NULL) { |
12 | { | ||
13 | /* ZZZZZZZZZZZZZZZZ */ | 13 | /* ZZZZZZZZZZZZZZZZ */ |
14 | return(NULL); | 14 | return (NULL); |
15 | } | 15 | } |
16 | memset(ret,0,sizeof(COMP_CTX)); | 16 | memset(ret, 0, sizeof(COMP_CTX)); |
17 | ret->meth=meth; | 17 | ret->meth = meth; |
18 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) | 18 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) { |
19 | { | ||
20 | free(ret); | 19 | free(ret); |
21 | ret=NULL; | 20 | ret = NULL; |
22 | } | ||
23 | return(ret); | ||
24 | } | 21 | } |
22 | return (ret); | ||
23 | } | ||
25 | 24 | ||
26 | void COMP_CTX_free(COMP_CTX *ctx) | 25 | void |
27 | { | 26 | COMP_CTX_free(COMP_CTX *ctx) |
28 | if(ctx == NULL) | 27 | { |
29 | return; | 28 | if (ctx == NULL) |
29 | return; | ||
30 | 30 | ||
31 | if (ctx->meth->finish != NULL) | 31 | if (ctx->meth->finish != NULL) |
32 | ctx->meth->finish(ctx); | 32 | ctx->meth->finish(ctx); |
33 | 33 | ||
34 | free(ctx); | 34 | free(ctx); |
35 | } | 35 | } |
36 | 36 | ||
37 | int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, | 37 | int |
38 | unsigned char *in, int ilen) | 38 | COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, |
39 | { | 39 | unsigned char *in, int ilen) |
40 | { | ||
40 | int ret; | 41 | int ret; |
41 | if (ctx->meth->compress == NULL) | 42 | |
42 | { | 43 | if (ctx->meth->compress == NULL) { |
43 | /* ZZZZZZZZZZZZZZZZZ */ | 44 | /* ZZZZZZZZZZZZZZZZZ */ |
44 | return(-1); | 45 | return (-1); |
45 | } | ||
46 | ret=ctx->meth->compress(ctx,out,olen,in,ilen); | ||
47 | if (ret > 0) | ||
48 | { | ||
49 | ctx->compress_in+=ilen; | ||
50 | ctx->compress_out+=ret; | ||
51 | } | ||
52 | return(ret); | ||
53 | } | 46 | } |
47 | ret = ctx->meth->compress(ctx, out, olen, in, ilen); | ||
48 | if (ret > 0) { | ||
49 | ctx->compress_in += ilen; | ||
50 | ctx->compress_out += ret; | ||
51 | } | ||
52 | return (ret); | ||
53 | } | ||
54 | 54 | ||
55 | int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, | 55 | int |
56 | unsigned char *in, int ilen) | 56 | COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, |
57 | { | 57 | unsigned char *in, int ilen) |
58 | { | ||
58 | int ret; | 59 | int ret; |
59 | 60 | ||
60 | if (ctx->meth->expand == NULL) | 61 | if (ctx->meth->expand == NULL) { |
61 | { | ||
62 | /* ZZZZZZZZZZZZZZZZZ */ | 62 | /* ZZZZZZZZZZZZZZZZZ */ |
63 | return(-1); | 63 | return (-1); |
64 | } | 64 | } |
65 | ret=ctx->meth->expand(ctx,out,olen,in,ilen); | 65 | ret = ctx->meth->expand(ctx, out, olen, in, ilen); |
66 | if (ret > 0) | 66 | if (ret > 0) { |
67 | { | 67 | ctx->expand_in += ilen; |
68 | ctx->expand_in+=ilen; | 68 | ctx->expand_out += ret; |
69 | ctx->expand_out+=ret; | ||
70 | } | ||
71 | return(ret); | ||
72 | } | 69 | } |
70 | return (ret); | ||
71 | } | ||