mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-02 09:01:38 -05:00
Merge pull request #88 from 4e554c4c/alloc_crashing
Prevent alloc errors from crashing
This commit is contained in:
commit
27c13d621d
13 changed files with 109 additions and 13 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue