wok view module-init-tools/stuff/lzlib.u @ rev 3320

Up: module-init-tools (3.9)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Jun 08 19:12:04 2009 +0200 (2009-06-08)
parents cf7f6d5ad5ca
children 71c7aacfbbb2
line source
1 --- module-init-tools-3.9/zlibsupport.c
2 +++ module-init-tools-3.9/zlibsupport.c
3 @@ -18,60 +18,40 @@
4 #include "testing.h"
6 #ifdef CONFIG_USE_ZLIB
7 -#include <zlib.h>
8 -
9 -void *grab_contents(gzFile *gzfd, unsigned long *size)
10 -{
11 - unsigned int max = 16384;
12 - void *buffer = NOFAIL(malloc(max));
13 - int ret;
14 -
15 - *size = 0;
16 - while ((ret = gzread(gzfd, buffer + *size, max - *size)) > 0) {
17 - *size += ret;
18 - if (*size == max)
19 - buffer = NOFAIL(realloc(buffer, max *= 2));
20 - }
21 - if (ret < 0) {
22 - free(buffer);
23 - buffer = NULL;
24 - }
25 -
26 - return buffer;
27 -}
28 +#include <lzlib.h>
30 void *grab_fd(int fd, unsigned long *size)
31 {
32 - gzFile gzfd;
33 + lzFile lzfd;
35 - gzfd = gzdopen(fd, "rb");
36 - if (!gzfd) {
37 + lzfd = lzdopen(fd, "rb");
38 + if (!lzfd) {
39 if (errno == ENOMEM)
40 fatal("Memory allocation failure in gzdopen\n");
41 return NULL;
42 }
44 - /* gzclose(gzfd) would close fd, which would drop locks.
45 + /* lzclose(lzfd) would close fd, which would drop locks.
46 Don't blame zlib: POSIX locking semantics are so horribly
47 broken that they should be ripped out. */
48 - return grab_contents(gzfd, size);
49 + return lzgrab(lzfd, size);
50 }
52 /* gzopen handles uncompressed files transparently. */
53 void *grab_file(const char *filename, unsigned long *size)
54 {
55 - gzFile gzfd;
56 + lzFile lzfd;
57 void *buffer;
59 errno = 0;
60 - gzfd = gzopen(filename, "rb");
61 - if (!gzfd) {
62 + lzfd = lzopen(filename, "rb");
63 + if (!lzfd) {
64 if (errno == ENOMEM)
65 fatal("Memory allocation failure in gzopen\n");
66 return NULL;
67 }
68 - buffer = grab_contents(gzfd, size);
69 - gzclose(gzfd);
70 + buffer = lzgrab(lzfd, size);
71 + lzclose(lzfd);
72 return buffer;
73 }
76 --- module-init-tools-3.9/configure
77 +++ module-init-tools-3.9/configure
78 @@ -2590,7 +2590,7 @@
79 #define CONFIG_USE_ZLIB 1
80 _ACEOF
82 - zlib_flags="-Wl,-Bstatic -lz -Wl,-Bdynamic"
83 + zlib_flags="-Wl,-Bdynamic -lz -llz"
84 fi
85 fi
87 @@ -2602,7 +2602,7 @@
88 #define CONFIG_USE_ZLIB 1
89 _ACEOF
91 - zlib_flags="-lz"
92 + zlib_flags="-lz -llz"
93 fi
94 fi