summaryrefslogtreecommitdiff
path: root/src/mkhelp.pl
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2008-04-21 23:17:20 +0000
committerDan Fandrich <dan@coneharvesters.com>2008-04-21 23:17:20 +0000
commit7076505c2495d2804a0b8f8f9b5901aa8f5dbf16 (patch)
tree7dfc12793f0cee8f03263bd51a70c2af68f642ba /src/mkhelp.pl
parent5825cf9457f2e6f327bd1f6bebbc8e925df13c16 (diff)
downloadcurl-7076505c2495d2804a0b8f8f9b5901aa8f5dbf16.tar.gz
Allocate the decompression buffer for the --manual option on the heap
instead of the stack.
Diffstat (limited to 'src/mkhelp.pl')
-rw-r--r--src/mkhelp.pl28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/mkhelp.pl b/src/mkhelp.pl
index 871aabcb3..7fb37db58 100644
--- a/src/mkhelp.pl
+++ b/src/mkhelp.pl
@@ -120,6 +120,7 @@ HEAD
;
if($c) {
print <<HEAD
+#include <stdlib.h>
#include <zlib.h>
static const unsigned char hugehelpgz[] = {
/* This mumbo-jumbo is the huge help text compressed with gzip.
@@ -144,10 +145,11 @@ HEAD
print "\n};\n";
print <<EOF
+#define BUF_SIZE 0x10000
/* Decompress and send to stdout a gzip-compressed buffer */
void hugehelp(void)
{
- unsigned char buf[0x10000];
+ unsigned char* buf;
int status,headerlen;
z_stream z;
@@ -165,17 +167,21 @@ void hugehelp(void)
if (inflateInit2(&z, -MAX_WBITS) != Z_OK)
return;
- while(1) {
- z.avail_out = (int)sizeof(buf);
- z.next_out = buf;
- status = inflate(&z, Z_SYNC_FLUSH);
- if (status == Z_OK || status == Z_STREAM_END) {
- fwrite(buf, sizeof(buf) - z.avail_out, 1, stdout);
- if (status == Z_STREAM_END)
- break;
+ buf = malloc(BUF_SIZE);
+ if (buf) {
+ while(1) {
+ z.avail_out = BUF_SIZE;
+ z.next_out = buf;
+ status = inflate(&z, Z_SYNC_FLUSH);
+ if (status == Z_OK || status == Z_STREAM_END) {
+ fwrite(buf, BUF_SIZE - z.avail_out, 1, stdout);
+ if (status == Z_STREAM_END)
+ break;
+ }
+ else
+ break; /* Error */
}
- else
- break; /* Error */
+ free(buf);
}
inflateEnd(&z);
}