comp20003-project02/common.c

21 lines
465 B
C

/* common.c
*
* Created by Rory Healy (healyr@student.unimelb.edu.au)
* Created on 25th August 2021
* Last modified 8th September 2021
*
* Contains functions for general use throughout other files.
*
*/
#ifndef COMMON_HEADER
#include "common.h"
#endif
/* Checks if a given pointer is null. Used for malloc() and realloc(). */
void checkNullPointer(void *ptr) {
if (!ptr) {
fputs("Error: Cannot allocate memory.\n", stderr);
exit(EXIT_FAILURE);
}
}