Free memory on error
Use talloc for hs_type

We'll probably need to audit the source for similar issues.
Or, simply convert everything to talloc, and the problems
will go away.
Use memcpy for binary structures, not strncpy
Remove dead code
Array entry always exists