Changeset 1032 for 1.8.3/trunk/src/comp_h.c
- Timestamp:
- 07/08/07 20:50:12 (1 year ago)
- Files:
-
- 1.8.3/trunk/src/comp_h.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
1.8.3/trunk/src/comp_h.c
r919 r1032 54 54 static CType ctable[TABLE_SIZE]; 55 55 static char ltable[TABLE_SIZE]; 56 57 slab *huffman_slab = NULL; 56 58 57 59 static int fix_tree_depth(CNode *node, int height, int zeros); … … 260 262 add_ones(node->right); 261 263 if ((count >= 7) || ((count >= 3) && !node->left && !node->right)) { 262 ctop = (CNode *) malloc((unsigned) sizeof(CNode));264 ctop = slab_malloc(huffman_slab, node); 263 265 if (!ctop) { 264 266 do_rawlog(LT_ERR, … … 337 339 #endif 338 340 341 huffman_slab = slab_create("huffman attribute compression", sizeof(CNode)); 342 slab_set_opt(huffman_slab, SLAB_ALLOC_BEST_FIT, 1); 343 339 344 /* Part 1: initialize */ 340 345 for (total = 0; total < TABLE_SIZE; total++) { 341 346 table[total].freq = 0; 342 table[total].node = (CNode *) malloc((unsigned) sizeof(CNode));347 table[total].node = slab_malloc(huffman_slab, NULL); 343 348 if (!table[total].node) { 344 349 do_rawlog(LT_ERR, … … 435 440 printf("\n"); 436 441 #endif 437 node = (CNode *) malloc((unsigned) sizeof(CNode));442 node = slab_malloc(huffman_slab, table[indx].node); 438 443 if (!node) { 439 444 do_rawlog(LT_ERR, … … 485 490 for (count = 0; node->left && (count < 4); count++) 486 491 node = node->left; 487 ctop = (CNode *) malloc((unsigned) sizeof(CNode));492 ctop = slab_malloc(huffman_slab, node); 488 493 if (!ctop) { 489 494 do_rawlog(LT_ERR, "Cannot allocate memory for compression tree. Aborting."); … … 509 514 for (count = 0; count < 8; count++) { 510 515 if (!node->left) { 511 ctop = (CNode *) malloc((unsigned) sizeof(CNode));516 ctop = slab_malloc(huffman_slab, node); 512 517 if (!ctop) { 513 518 do_rawlog(LT_ERR,
