| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/comp/comp_lib.c |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /* $OpenBSD: comp_lib.c,v 1.8 2014/11/03 16:58:28 tedu Exp $ */ | - | ||||||||||||
| 2 | #include <stdio.h> | - | ||||||||||||
| 3 | #include <stdlib.h> | - | ||||||||||||
| 4 | #include <string.h> | - | ||||||||||||
| 5 | #include <openssl/objects.h> | - | ||||||||||||
| 6 | #include <openssl/comp.h> | - | ||||||||||||
| 7 | - | |||||||||||||
| 8 | COMP_CTX * | - | ||||||||||||
| 9 | COMP_CTX_new(COMP_METHOD *meth) | - | ||||||||||||
| 10 | { | - | ||||||||||||
| 11 | COMP_CTX *ret; | - | ||||||||||||
| 12 | - | |||||||||||||
| 13 | if ((ret = calloc(1, sizeof(COMP_CTX))) == NULL) {
| 0 | ||||||||||||
| 14 | return (NULL); never executed: return ( ((void *)0) ); | 0 | ||||||||||||
| 15 | } | - | ||||||||||||
| 16 | ret->meth = meth; | - | ||||||||||||
| 17 | if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
| 0 | ||||||||||||
| 18 | free(ret); | - | ||||||||||||
| 19 | ret = NULL; | - | ||||||||||||
| 20 | } never executed: end of block | 0 | ||||||||||||
| 21 | return (ret); never executed: return (ret); | 0 | ||||||||||||
| 22 | } | - | ||||||||||||
| 23 | - | |||||||||||||
| 24 | void | - | ||||||||||||
| 25 | COMP_CTX_free(COMP_CTX *ctx) | - | ||||||||||||
| 26 | { | - | ||||||||||||
| 27 | if (ctx == NULL)
| 0-1 | ||||||||||||
| 28 | return; executed 1 time by 1 test: return;Executed by:
| 1 | ||||||||||||
| 29 | - | |||||||||||||
| 30 | if (ctx->meth->finish != NULL)
| 0 | ||||||||||||
| 31 | ctx->meth->finish(ctx); never executed: ctx->meth->finish(ctx); | 0 | ||||||||||||
| 32 | - | |||||||||||||
| 33 | free(ctx); | - | ||||||||||||
| 34 | } never executed: end of block | 0 | ||||||||||||
| 35 | - | |||||||||||||
| 36 | int | - | ||||||||||||
| 37 | COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, | - | ||||||||||||
| 38 | unsigned char *in, int ilen) | - | ||||||||||||
| 39 | { | - | ||||||||||||
| 40 | int ret; | - | ||||||||||||
| 41 | - | |||||||||||||
| 42 | if (ctx->meth->compress == NULL) {
| 0 | ||||||||||||
| 43 | return (-1); never executed: return (-1); | 0 | ||||||||||||
| 44 | } | - | ||||||||||||
| 45 | ret = ctx->meth->compress(ctx, out, olen, in, ilen); | - | ||||||||||||
| 46 | if (ret > 0) {
| 0 | ||||||||||||
| 47 | ctx->compress_in += ilen; | - | ||||||||||||
| 48 | ctx->compress_out += ret; | - | ||||||||||||
| 49 | } never executed: end of block | 0 | ||||||||||||
| 50 | return (ret); never executed: return (ret); | 0 | ||||||||||||
| 51 | } | - | ||||||||||||
| 52 | - | |||||||||||||
| 53 | int | - | ||||||||||||
| 54 | COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, | - | ||||||||||||
| 55 | unsigned char *in, int ilen) | - | ||||||||||||
| 56 | { | - | ||||||||||||
| 57 | int ret; | - | ||||||||||||
| 58 | - | |||||||||||||
| 59 | if (ctx->meth->expand == NULL) {
| 0 | ||||||||||||
| 60 | return (-1); never executed: return (-1); | 0 | ||||||||||||
| 61 | } | - | ||||||||||||
| 62 | ret = ctx->meth->expand(ctx, out, olen, in, ilen); | - | ||||||||||||
| 63 | if (ret > 0) {
| 0 | ||||||||||||
| 64 | ctx->expand_in += ilen; | - | ||||||||||||
| 65 | ctx->expand_out += ret; | - | ||||||||||||
| 66 | } never executed: end of block | 0 | ||||||||||||
| 67 | return (ret); never executed: return (ret); | 0 | ||||||||||||
| 68 | } | - | ||||||||||||
| Source code | Switch to Preprocessed file |