From c76fe802e434cd47e22cc76630212686e428dab1 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Sun, 17 Jun 2012 13:55:46 +0100 Subject: [PATCH] Some minor mods and fixes to the huffman decoder. --- src/huffman.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/huffman.c b/src/huffman.c index fef49b38..b9c68bb0 100644 --- a/src/huffman.c +++ b/src/huffman.c @@ -35,8 +35,11 @@ void huffman_tree_destroy ( huffman_node_t *n ) huffman_node_t *huffman_tree_load ( const char *path ) { htsmsg_t *m; + huffman_node_t *ret; if (!(m = hts_settings_load(path))) return NULL; - return huffman_tree_build(m); + ret = huffman_tree_build(m); + htsmsg_destroy(m); + return ret; } huffman_node_t *huffman_tree_build ( htsmsg_t *m ) @@ -68,8 +71,6 @@ huffman_node_t *huffman_tree_build ( htsmsg_t *m ) node->data = strdup(data); } } - - htsmsg_destroy(m); return root; } @@ -77,7 +78,7 @@ char *huffman_decode ( huffman_node_t *tree, const char *data, size_t len, uint8_t mask ) { char* ret; - size_t nalloc = len, nused = 0; + size_t nalloc = len*4, nused = 0; huffman_node_t *node = tree; if (!len) return NULL; @@ -104,6 +105,7 @@ char *huffman_decode } } mask = 0x80; + data++; } return ret; }