Prevent alloc errors from crashing in list_t

This commit changes the `list_t` api so that alloc errors can be
detected and worked around. Also fixes errors not found in 5cc7342
This commit is contained in:
Calvin Lee 2017-08-16 09:23:21 +02:00
parent 19d6442f52
commit 901c14c409
8 changed files with 103 additions and 25 deletions

View file

@ -65,7 +65,9 @@ static void handle_touch_down(struct touch_state *tstate, int32_t slot,
point->slot = slot;
point->x = x / width;
point->y = y / height;
list_add(sample->touch_points, point);
if (list_add(sample->touch_points, point) == -1) {
free(point);
}
}
static void handle_touch_up(struct touch_state *tstate, int32_t slot) {