Remove extraneous malloc()/free()s in gethash(). The pointer returned needs to be freed by the caller.