Check for failed allocations in libhdfs code

This commit adds checks for failed allocations in hdfs.c for Hadoop
versions 1.x.  Version 2.x seem to be ok.
Merge pull request #44 from ilveroluca/libhdfs_check_allocations

Check for failed allocations in libhdfs code