Added some sanity checking to SDF buffer allocation.

The sdf_output_point routines allocate a large buffer to use when
writing out data. On memory constrained systems this allocation can
occasionally fail.
With this patch, the SDF library now checks for failure and attempts to
use a smaller buffer.
Sanity tests should also be added to other SDF routines at some point.
Fixed a few valgrind errors.
Only write the summary block from rank zero.