Fix for gres type data structures

Attempted to free variable that was not a pointer
bug 1166
Define safe strncmp() (for NULL args)
harden gres code

This adds checks for NULL pointers in the gres data structures
to avoid memory references including string compares with NULL
pointers.