i would like to add one more point, though its not really necessary , it will still work without this Check, but its adviced to have these checks.
if(NULL != p)
//Check to see proper allocation of memory
....Do your Stuff....
//Not enough memory