summaryrefslogtreecommitdiff
path: root/archival/bz/huffman.c
diff options
context:
space:
mode:
authorDenis Vlasenko2007-12-02 08:35:37 +0000
committerDenis Vlasenko2007-12-02 08:35:37 +0000
commitab801874f852312787c049272c20b14e06ed8195 (patch)
tree1cfd38cfe48ed6a6625ce559ab7f3e5778a980be /archival/bz/huffman.c
parent8003e266edbc0ec62a586dd70dcc80dc13e2dbf0 (diff)
downloadbusybox-ab801874f852312787c049272c20b14e06ed8195.zip
busybox-ab801874f852312787c049272c20b14e06ed8195.tar.gz
attack the biggest stack users:
-mkfs_minix_main [busybox_unstripped]: 4288 -mkfs_minix_main [busybox_unstripped]: 4276 -grave [busybox_unstripped]: 4260 (bzip2 users too - not listed) price we pay in code size increase: mainSort 2458 2515 +57 grave 1005 1058 +53 sendMTFValues 2177 2195 +18 BZ2_blockSort 122 125 +3 mkfs_minix_main 3070 3022 -48 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/1 up/down: 131/-48) Total: 83 bytes
Diffstat (limited to 'archival/bz/huffman.c')
-rw-r--r--archival/bz/huffman.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/archival/bz/huffman.c b/archival/bz/huffman.c
index 02838c4..676b1af 100644
--- a/archival/bz/huffman.c
+++ b/archival/bz/huffman.c
@@ -98,7 +98,8 @@ void DOWNHEAP1(int32_t *heap, int32_t *weight, int32_t nHeap)
/*---------------------------------------------------*/
static
-void BZ2_hbMakeCodeLengths(uint8_t *len,
+void BZ2_hbMakeCodeLengths(EState *s,
+ uint8_t *len,
int32_t *freq,
int32_t alphaSize,
int32_t maxLen)
@@ -110,9 +111,14 @@ void BZ2_hbMakeCodeLengths(uint8_t *len,
int32_t nNodes, nHeap, n1, n2, i, j, k;
Bool tooLong;
+ /* bbox: moved to EState to save stack
int32_t heap [BZ_MAX_ALPHA_SIZE + 2];
int32_t weight[BZ_MAX_ALPHA_SIZE * 2];
int32_t parent[BZ_MAX_ALPHA_SIZE * 2];
+ */
+#define heap (s->BZ2_hbMakeCodeLengths__heap)
+#define weight (s->BZ2_hbMakeCodeLengths__weight)
+#define parent (s->BZ2_hbMakeCodeLengths__parent)
for (i = 0; i < alphaSize; i++)
weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
@@ -189,6 +195,9 @@ void BZ2_hbMakeCodeLengths(uint8_t *len,
weight[i] = j << 8;
}
}
+#undef heap
+#undef weight
+#undef parent
}