Warning messages are printed if memory can not be allocated using malloc/calloc. Added missed call of free() function etc.