From 37438ca202a9a1f4e782f1d1803686fc6b65e918 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Wed, 12 Nov 2008 23:25:26 +0000 Subject: Move static function prototypes from nbench1.h to appropriate files git-svn-id: svn://mattst88.com/svn/cleanbench/trunk@14 0d43b9a7-5ab2-4d7b-af9d-f64450cef757 --- huffman.c | 51 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 8 deletions(-) (limited to 'huffman.c') diff --git a/huffman.c b/huffman.c index 961fc08..063b2ad 100644 --- a/huffman.c +++ b/huffman.c @@ -3,13 +3,52 @@ #include "nmglobal.h" #include "nbench1.h" + +/************************ +** HUFFMAN COMPRESSION ** +************************/ + +/* +** DEFINES +*/ +#define EXCLUDED 32000L /* Big positive value */ + +/* +** TYPEDEFS +*/ +typedef struct { + unsigned char c; /* Byte value */ + float freq; /* Frequency */ + int parent; /* Parent node */ + int left; /* Left pointer = 0 */ + int right; /* Right pointer = 1 */ +} huff_node; + +/* +** GLOBALS +*/ +static huff_node *hufftree; /* The huffman tree */ +static long plaintextlen; /* Length of plaintext */ + +/* +** PROTOTYPES +*/ +static void create_text_line(char *dt,long nchars); +static void create_text_block(char *tb, unsigned long tblen, + unsigned short maxlinlen); +static unsigned long DoHuffIteration(char *plaintext, + char *comparray, char *decomparray, + unsigned long arraysize, unsigned long nloops, huff_node *hufftree); +static void SetCompBit(uint8_t *comparray, uint32_t bitoffset, char bitchar); +static int GetCompBit(uint8_t *comparray, uint32_t bitoffset); + /* ** Word catalog */ #define WORDCATSIZE 50 -char *wordcatarray[WORDCATSIZE] = -{ "Hello", +char *wordcatarray[WORDCATSIZE] = { /* FIXME: const? */ + "Hello", "He", "Him", "the", @@ -58,12 +97,8 @@ char *wordcatarray[WORDCATSIZE] = "used", "shown", "you", - "know" }; - - -/************************ -** HUFFMAN COMPRESSION ** -************************/ + "know" +}; /************** ** DoHuffman ** -- cgit v1.2.3