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.