[PATCH libinput 2/3] Replace calloc calls with zalloc
Peter Hutterer
peter.hutterer at who-t.net
Fri Jul 7 01:55:54 UTC 2017
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/evdev-mt-touchpad.c | 4 +---
src/evdev.c | 4 +---
src/filter.c | 4 ++--
test/litest.c | 4 ++--
4 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 4a6e47cc..c6290284 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -2018,9 +2018,7 @@ tp_init_slots(struct tp_dispatch *tp,
}
tp->ntouches = max(tp->num_slots, n_btn_tool_touches);
- tp->touches = calloc(tp->ntouches, sizeof(struct tp_touch));
- if (!tp->touches)
- return false;
+ tp->touches = zalloc(tp->ntouches * sizeof(struct tp_touch));
for (i = 0; i < tp->ntouches; i++)
tp_init_touch(tp, &tp->touches[i]);
diff --git a/src/evdev.c b/src/evdev.c
index e9326185..5d146c8d 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1775,9 +1775,7 @@ fallback_dispatch_init_slots(struct fallback_dispatch *dispatch,
active_slot = libevdev_get_current_slot(evdev);
}
- slots = calloc(num_slots, sizeof(struct mt_slot));
- if (!slots)
- return -1;
+ slots = zalloc(num_slots * sizeof(struct mt_slot));
for (slot = 0; slot < num_slots; ++slot) {
slots[slot].seat_slot = -1;
diff --git a/src/filter.c b/src/filter.c
index ba4da5f1..65e83197 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -954,7 +954,7 @@ create_default_filter(int dpi)
filter->last_velocity = 0.0;
filter->trackers =
- calloc(NUM_POINTER_TRACKERS, sizeof *filter->trackers);
+ zalloc(NUM_POINTER_TRACKERS * sizeof *filter->trackers);
filter->cur_tracker = 0;
filter->threshold = DEFAULT_THRESHOLD;
@@ -1052,7 +1052,7 @@ create_pointer_accelerator_filter_lenovo_x230(int dpi)
filter->last_velocity = 0.0;
filter->trackers =
- calloc(NUM_POINTER_TRACKERS, sizeof *filter->trackers);
+ zalloc(NUM_POINTER_TRACKERS * sizeof *filter->trackers);
filter->cur_tracker = 0;
filter->threshold = X230_THRESHOLD;
diff --git a/test/litest.c b/test/litest.c
index ead3371c..23395413 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -1067,7 +1067,7 @@ merge_absinfo(const struct input_absinfo *orig,
if (!orig)
return NULL;
- abs = calloc(sz, sizeof(*abs));
+ abs = zalloc(sz * sizeof(*abs));
litest_assert(abs != NULL);
nelem = 0;
@@ -1101,7 +1101,7 @@ merge_events(const int *orig, const int *override)
if (!orig)
return NULL;
- events = calloc(sz, sizeof(int));
+ events = zalloc(sz * sizeof(int));
litest_assert(events != NULL);
nelem = 0;
--
2.13.0
More information about the wayland-devel
mailing list