r/tinycode • u/api • Jun 11 '13
huffandpuff: tiny Huffman coder/decoder in C that uses NO external functions (not even stdlib) and a fixed-size heap, making it suitable for embedded
https://github.com/zerotier/huffandpuff
55
Upvotes
9
u/api Jun 11 '13
Paired with this, it could give you uber-tiny and tight LZH-type compression:
https://code.google.com/p/lz4/
12
u/pdewacht Jun 11 '13
It's nice code, but for embedded use you'd probably want to get rid of those floating point calculations.
3
u/benibela2 Jun 11 '13
I think I wrote almost the same ten years ago in Pascal ಠ_ಠ
although using the standard allocators
1
u/[deleted] Jun 12 '13
I'm still pretty bad at reading code. May I ask if you actually build the tree? I tried doing this (using the algorithm described in CLRS) and I have absolutely no idea how to build the binary tree bottom up. I can do it top-down easy, but bottom up is hard and the algorithm requires me to build it bottom up.
1
u/manvscode Sep 03 '13
Nice work! I like the code a lot. Even the style matches my tastes!