GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/libcrypto/comp/comp_lib.c Lines: 0 24 0.0 %
Date: 2017-11-07 Branches: 0 18 0.0 %

Line Branch Exec Source
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) {
14
		return (NULL);
15
	}
16
	ret->meth = meth;
17
	if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
18
		free(ret);
19
		ret = NULL;
20
	}
21
	return (ret);
22
}
23
24
void
25
COMP_CTX_free(COMP_CTX *ctx)
26
{
27
	if (ctx == NULL)
28
		return;
29
30
	if (ctx->meth->finish != NULL)
31
		ctx->meth->finish(ctx);
32
33
	free(ctx);
34
}
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) {
43
		return (-1);
44
	}
45
	ret = ctx->meth->compress(ctx, out, olen, in, ilen);
46
	if (ret > 0) {
47
		ctx->compress_in += ilen;
48
		ctx->compress_out += ret;
49
	}
50
	return (ret);
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) {
60
		return (-1);
61
	}
62
	ret = ctx->meth->expand(ctx, out, olen, in, ilen);
63
	if (ret > 0) {
64
		ctx->expand_in += ilen;
65
		ctx->expand_out += ret;
66
	}
67
	return (ret);
68
}