-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrapzl.c
More file actions
57 lines (40 loc) · 1.28 KB
/
wrapzl.c
File metadata and controls
57 lines (40 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* ====================================================================
* Copyright (c) 2002 Johnny Shelley. All rights reserved.
*
* Bcrypt is licensed under the BSD software license. See the file
* called 'LICENSE' that you should have received with this software
* for details
* ====================================================================
*/
#include "includes.h"
#include "defines.h"
#include "functions.h"
uLong docompress(char **input, uLong sz) {
uLong newsz;
char *output;
newsz = sz + (sz *.1) + 13;
if ((output = malloc(newsz + 1)) == NULL)
memerror();
memset(output, 0, newsz + 1);
compress((Bytef *) output, &newsz, (const Bytef *) *input, sz);
free(*input);
if ((*input = malloc(newsz)) == NULL)
memerror();
memcpy(*input, output, newsz);
free(output);
return(newsz);
}
uLong douncompress(char **input, uLong sz, BCoptions options) {
char *output;
if ((output = malloc(options.origsize + 1)) == NULL)
memerror();
memset(output, 0, options.origsize + 1);
uncompress((Bytef *) output, (uLong *) &options.origsize,
(const Bytef *) *input, sz);
free(*input);
if ((*input = malloc(options.origsize)) == NULL)
memerror();
memcpy(*input, output, options.origsize);
free(output);
return(options.origsize);
}