Add checks for malloc failure and add error exit in case of malloc failure. Add rcsid. Submitted by: charnier
Submitted by: charnier