...
Always check that malloc() returns a non-null pointer, as per void MEM32-C. Detect and handle memory allocation errors.
It is important to retain any pointer value returned by malloc() so that the referenced memory may eventually be deallocated. One possible way to preserve such a value is to use a constant pointer:
...