cw.c: abstract out checked malloc into a function.