All pastes #452833 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-04-22 15:31 UTC
rendered paste body
#define arrsize(arr) (sizeof(arr)*sizeof((arr)[0]))

void compress(const char * data, size_t nData, ostream & out)
{
    // Create histogram
    int histogramTMP[256];
    memset( histogramTMP, 0, arrsize(histogramTMP) );

    for (size_t i = 0; i < nData; i++) {
        cout << data[i] << ' ' << (int)data[i] << endl;
        histogramTMP[(int)data[i]]++;
    }

    // snip
}

// Some gdb output that is making me go WTF?
/*
(gdb) break compress
Breakpoint 1 at 0x804bc28: file compress.cpp, line 18.
(gdb) r
Starting program: /Documents/uct/CSC2001F/tut5/tut5

Breakpoint 1, compress (data=0xbf9e41f0 "The fat cat jumped over the hat", nData=32, out=@0x804e558) at compress.cpp:18
18          memset( histogramTMP, 0, arrsize(histogramTMP) );
(gdb) break 34
Breakpoint 2 at 0x804bd7c: file compress.cpp, line 34.
(gdb) c
Continuing.

Breakpoint 2, compress (data=0x0, nData=0, out=@0x0) at compress.cpp:36
36          HuffmanNode *n = HuffmanNode::computeHuffmanTree(histogram, nHistogram);
(gdb) print histogramTMP
$1 = {0 <repeats 256 times>}
*/