add check to malloc calls
This commit is contained in:
12
test/test.c
12
test/test.c
@@ -57,8 +57,20 @@ int main(int argc, char **argv) {
|
||||
int failed = 0;
|
||||
|
||||
test_case = malloc(sizeof(int) * n);
|
||||
if (test_case == NULL) {
|
||||
fprintf("Error: Out of heap space!\n");
|
||||
exit(1);
|
||||
}
|
||||
qarray = malloc(sizeof(int) * n);
|
||||
if (qarray == NULL) {
|
||||
fprintf("Error: Out of heap space!\n");
|
||||
exit(1);
|
||||
}
|
||||
test_array = malloc(sizeof(int) * n);
|
||||
if (test_array == NULL) {
|
||||
fprintf("Error: Out of heap space!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
atexit(cleanup);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user