Refactor memory allocation in huffman decoder