Merge pull request #88 from 4e554c4c/alloc_crashing

Prevent alloc errors from crashing
This commit is contained in:
Drew DeVault 2017-08-15 12:21:58 -04:00 committed by GitHub
commit 27c13d621d
13 changed files with 109 additions and 13 deletions

View file

@ -6,9 +6,16 @@
list_t *list_create(void) {
list_t *list = malloc(sizeof(list_t));
if (!list) {
return NULL;
}
list->capacity = 10;
list->length = 0;
list->items = malloc(sizeof(void*) * list->capacity);
if (!list->items) {
free(list);
return NULL;
}
return list;
}