Memory allocation

- Test for NULL after allocation
- Use of calloc instead of malloc