Malloc in C Explained
Created: 2022-06-25 Tags: #permanent
Always check if malloc can't give any memory anymore.
int *list = malloc(3 * sizeof(int)); if (list == NULL) { // I'm just going to clean up and quit free(list); return 1; } Copy
int *list = malloc(3 * sizeof(int)); if (list == NULL) { // I'm just going to clean up and quit free(list); return 1; }