aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/cairo-buffer.c2
-rw-r--r--examples/foreign-toplevel.c2
-rw-r--r--examples/fullscreen-shell.c3
-rw-r--r--examples/gamma-control.c2
-rw-r--r--examples/output-layout.c4
-rw-r--r--examples/output-power-management.c2
-rw-r--r--examples/pointer.c6
-rw-r--r--examples/relative-pointer-unstable-v1.c4
-rw-r--r--examples/rotation.c4
-rw-r--r--examples/scene-graph.c5
-rw-r--r--examples/simple.c6
-rw-r--r--examples/tablet.c8
-rw-r--r--examples/text-input.c6
-rw-r--r--examples/touch.c8
14 files changed, 29 insertions, 33 deletions
diff --git a/examples/cairo-buffer.c b/examples/cairo-buffer.c
index 688b9910..d92a2f13 100644
--- a/examples/cairo-buffer.c
+++ b/examples/cairo-buffer.c
@@ -101,7 +101,7 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) {
wlr_output_init_render(wlr_output, server->allocator, server->renderer);
- struct output *output = calloc(1, sizeof(struct output));
+ struct output *output = calloc(1, sizeof(*output));
output->wlr = wlr_output;
output->server = server;
output->frame.notify = output_handle_frame;
diff --git a/examples/foreign-toplevel.c b/examples/foreign-toplevel.c
index 2d16f77b..8bb62c83 100644
--- a/examples/foreign-toplevel.c
+++ b/examples/foreign-toplevel.c
@@ -252,7 +252,7 @@ static const struct zwlr_foreign_toplevel_handle_v1_listener toplevel_impl = {
static void toplevel_manager_handle_toplevel(void *data,
struct zwlr_foreign_toplevel_manager_v1 *toplevel_manager,
struct zwlr_foreign_toplevel_handle_v1 *zwlr_toplevel) {
- struct toplevel_v1 *toplevel = calloc(1, sizeof(struct toplevel_v1));
+ struct toplevel_v1 *toplevel = calloc(1, sizeof(*toplevel));
if (!toplevel) {
fprintf(stderr, "Failed to allocate memory for toplevel\n");
return;
diff --git a/examples/fullscreen-shell.c b/examples/fullscreen-shell.c
index aa55adb8..70b7f676 100644
--- a/examples/fullscreen-shell.c
+++ b/examples/fullscreen-shell.c
@@ -154,8 +154,7 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) {
wlr_output_init_render(wlr_output, server->allocator, server->renderer);
- struct fullscreen_output *output =
- calloc(1, sizeof(struct fullscreen_output));
+ struct fullscreen_output *output = calloc(1, sizeof(*output));
output->wlr_output = wlr_output;
output->server = server;
output->frame.notify = output_handle_frame;
diff --git a/examples/gamma-control.c b/examples/gamma-control.c
index 9fa00ce3..69d1cd75 100644
--- a/examples/gamma-control.c
+++ b/examples/gamma-control.c
@@ -87,7 +87,7 @@ static const struct zwlr_gamma_control_v1_listener gamma_control_listener = {
static void registry_handle_global(void *data, struct wl_registry *registry,
uint32_t name, const char *interface, uint32_t version) {
if (strcmp(interface, wl_output_interface.name) == 0) {
- struct output *output = calloc(1, sizeof(struct output));
+ struct output *output = calloc(1, sizeof(*output));
output->wl_output = wl_registry_bind(registry, name,
&wl_output_interface, 1);
wl_list_insert(&outputs, &output->link);
diff --git a/examples/output-layout.c b/examples/output-layout.c
index 99d403e0..de5217e4 100644
--- a/examples/output-layout.c
+++ b/examples/output-layout.c
@@ -168,7 +168,7 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
wlr_output_init_render(output, sample->allocator, sample->renderer);
- struct sample_output *sample_output = calloc(1, sizeof(struct sample_output));
+ struct sample_output *sample_output = calloc(1, sizeof(*sample_output));
wlr_output_layout_add_auto(sample->layout, output);
sample_output->output = output;
sample_output->sample = sample;
@@ -236,7 +236,7 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
struct sample_state *sample = wl_container_of(listener, sample, new_input);
switch (device->type) {
case WLR_INPUT_DEVICE_KEYBOARD:;
- struct sample_keyboard *keyboard = calloc(1, sizeof(struct sample_keyboard));
+ struct sample_keyboard *keyboard = calloc(1, sizeof(*keyboard));
keyboard->wlr_keyboard = wlr_keyboard_from_input_device(device);
keyboard->sample = sample;
wl_signal_add(&device->events.destroy, &keyboard->destroy);
diff --git a/examples/output-power-management.c b/examples/output-power-management.c
index 00d4122a..c06eae61 100644
--- a/examples/output-power-management.c
+++ b/examples/output-power-management.c
@@ -49,7 +49,7 @@ static const struct zwlr_output_power_v1_listener output_power_listener = {
static void registry_handle_global(void *data, struct wl_registry *registry,
uint32_t name, const char *interface, uint32_t version) {
if (strcmp(interface, wl_output_interface.name) == 0) {
- struct output *output = calloc(1, sizeof(struct output));
+ struct output *output = calloc(1, sizeof(*output));
output->wl_output = wl_registry_bind(registry, name,
&wl_output_interface, 1);
wl_list_insert(&outputs, &output->link);
diff --git a/examples/pointer.c b/examples/pointer.c
index 86986503..5d9de33b 100644
--- a/examples/pointer.c
+++ b/examples/pointer.c
@@ -194,7 +194,7 @@ static void handle_touch_up(struct wl_listener *listener, void *data) {
static void handle_touch_down(struct wl_listener *listener, void *data) {
struct sample_state *sample = wl_container_of(listener, sample, touch_down);
struct wlr_touch_down_event *event = data;
- struct touch_point *point = calloc(1, sizeof(struct touch_point));
+ struct touch_point *point = calloc(1, sizeof(*point));
point->touch_id = event->touch_id;
point->x = event->x;
point->y = event->y;
@@ -266,7 +266,7 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
wlr_output_init_render(output, sample->allocator, sample->renderer);
- struct sample_output *sample_output = calloc(1, sizeof(struct sample_output));
+ struct sample_output *sample_output = calloc(1, sizeof(*sample_output));
sample_output->output = output;
sample_output->state = sample;
wl_signal_add(&output->events.frame, &sample_output->frame);
@@ -305,7 +305,7 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
break;
case WLR_INPUT_DEVICE_KEYBOARD:;
- struct sample_keyboard *keyboard = calloc(1, sizeof(struct sample_keyboard));
+ struct sample_keyboard *keyboard = calloc(1, sizeof(*keyboard));
keyboard->wlr_keyboard = wlr_keyboard_from_input_device(device);
keyboard->state = state;
wl_signal_add(&device->events.destroy, &keyboard->destroy);
diff --git a/examples/relative-pointer-unstable-v1.c b/examples/relative-pointer-unstable-v1.c
index 7d370bba..6722a5b9 100644
--- a/examples/relative-pointer-unstable-v1.c
+++ b/examples/relative-pointer-unstable-v1.c
@@ -437,7 +437,7 @@ int main(int argc, char **argv) {
/* Initialize EGL context */
- struct egl_info *e = calloc(1, sizeof(struct egl_info));
+ struct egl_info *e = calloc(1, sizeof(*e));
e->width = e->height = 512;
egl_init(display);
@@ -465,7 +465,7 @@ int main(int argc, char **argv) {
/* Setup global state and render */
- struct window *w = calloc(1, sizeof(struct window));
+ struct window *w = calloc(1, sizeof(*w));
w->egl_info = e;
draw_init(e);
diff --git a/examples/rotation.c b/examples/rotation.c
index e092a363..203b208e 100644
--- a/examples/rotation.c
+++ b/examples/rotation.c
@@ -119,7 +119,7 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
wlr_output_init_render(output, sample->allocator, sample->renderer);
- struct sample_output *sample_output = calloc(1, sizeof(struct sample_output));
+ struct sample_output *sample_output = calloc(1, sizeof(*sample_output));
sample_output->x_offs = sample_output->y_offs = 0;
sample_output->x_vel = sample_output->y_vel = 128;
@@ -187,7 +187,7 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
struct sample_state *sample = wl_container_of(listener, sample, new_input);
switch (device->type) {
case WLR_INPUT_DEVICE_KEYBOARD:;
- struct sample_keyboard *keyboard = calloc(1, sizeof(struct sample_keyboard));
+ struct sample_keyboard *keyboard = calloc(1, sizeof(*keyboard));
keyboard->wlr_keyboard = wlr_keyboard_from_input_device(device);
keyboard->sample = sample;
wl_signal_add(&device->events.destroy, &keyboard->destroy);
diff --git a/examples/scene-graph.c b/examples/scene-graph.c
index 7b7e14d6..03ad8141 100644
--- a/examples/scene-graph.c
+++ b/examples/scene-graph.c
@@ -72,8 +72,7 @@ static void server_handle_new_output(struct wl_listener *listener, void *data) {
wlr_output_init_render(wlr_output, server->allocator, server->renderer);
- struct output *output =
- calloc(1, sizeof(struct output));
+ struct output *output = calloc(1, sizeof(*output));
output->wlr = wlr_output;
output->server = server;
output->frame.notify = output_handle_frame;
@@ -118,7 +117,7 @@ static void server_handle_new_surface(struct wl_listener *listener,
int pos = server->surface_offset;
server->surface_offset += 50;
- struct surface *surface = calloc(1, sizeof(struct surface));
+ struct surface *surface = calloc(1, sizeof(*surface));
surface->wlr = wlr_surface;
surface->commit.notify = surface_handle_commit;
wl_signal_add(&wlr_surface->events.commit, &surface->commit);
diff --git a/examples/simple.c b/examples/simple.c
index 781ee0e9..8fe49460 100644
--- a/examples/simple.c
+++ b/examples/simple.c
@@ -97,8 +97,7 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
wlr_output_init_render(output, sample->allocator, sample->renderer);
- struct sample_output *sample_output =
- calloc(1, sizeof(struct sample_output));
+ struct sample_output *sample_output = calloc(1, sizeof(*sample_output));
sample_output->output = output;
sample_output->sample = sample;
wl_signal_add(&output->events.frame, &sample_output->frame);
@@ -146,8 +145,7 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
struct sample_state *sample = wl_container_of(listener, sample, new_input);
switch (device->type) {
case WLR_INPUT_DEVICE_KEYBOARD:;
- struct sample_keyboard *keyboard =
- calloc(1, sizeof(struct sample_keyboard));
+ struct sample_keyboard *keyboard = calloc(1, sizeof(*keyboard));
keyboard->wlr_keyboard = wlr_keyboard_from_input_device(device);
keyboard->sample = sample;
wl_signal_add(&device->events.destroy, &keyboard->destroy);
diff --git a/examples/tablet.c b/examples/tablet.c
index c992e0a4..c253526d 100644
--- a/examples/tablet.c
+++ b/examples/tablet.c
@@ -270,7 +270,7 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
wlr_output_init_render(output, sample->allocator, sample->renderer);
- struct sample_output *sample_output = calloc(1, sizeof(struct sample_output));
+ struct sample_output *sample_output = calloc(1, sizeof(*sample_output));
sample_output->output = output;
sample_output->sample = sample;
wl_signal_add(&output->events.frame, &sample_output->frame);
@@ -317,7 +317,7 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
struct sample_state *sample = wl_container_of(listener, sample, new_input);
switch (device->type) {
case WLR_INPUT_DEVICE_KEYBOARD:;
- struct sample_keyboard *keyboard = calloc(1, sizeof(struct sample_keyboard));
+ struct sample_keyboard *keyboard = calloc(1, sizeof(*keyboard));
keyboard->wlr_keyboard = wlr_keyboard_from_input_device(device);
keyboard->sample = sample;
wl_signal_add(&device->events.destroy, &keyboard->destroy);
@@ -340,7 +340,7 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
xkb_context_unref(context);
break;
case WLR_INPUT_DEVICE_TABLET_PAD:;
- struct tablet_pad_state *pstate = calloc(sizeof(struct tablet_pad_state), 1);
+ struct tablet_pad_state *pstate = calloc(1, sizeof(*pstate));
pstate->wlr_tablet_pad = wlr_tablet_pad_from_input_device(device);
pstate->sample = sample;
pstate->destroy.notify = tablet_pad_destroy_notify;
@@ -358,7 +358,7 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
sample->height_mm = tablet->height_mm == 0 ?
10 : tablet->height_mm;
- struct tablet_tool_state *tstate = calloc(sizeof(struct tablet_tool_state), 1);
+ struct tablet_tool_state *tstate = calloc(1, sizeof(*tstate));
tstate->wlr_tablet = tablet;
tstate->sample = sample;
tstate->destroy.notify = tablet_tool_destroy_notify;
diff --git a/examples/text-input.c b/examples/text-input.c
index 2f530d27..dba4ce18 100644
--- a/examples/text-input.c
+++ b/examples/text-input.c
@@ -121,7 +121,7 @@ static void show_status(void) {
for (unsigned i = 0; i < utf8_strlen(buffer); i++) {
printf(" ");
}
- char *cursor_mark = calloc(utf8_strlen(preedit_text) + 2, sizeof(char));
+ char *cursor_mark = calloc(utf8_strlen(preedit_text) + 2, sizeof(*cursor_mark));
for (unsigned i = 0; i < utf8_strlen(preedit_text); i++) {
cursor_mark[i] = '.';
}
@@ -249,7 +249,7 @@ static void text_input_handle_done(void *data,
commit_string = "";
}
size_t new_size = strlen(buffer) + strlen(commit_string) + 1;
- char *new_buffer = calloc(new_size, sizeof(char)); // realloc may fail anyway
+ char *new_buffer = calloc(new_size, sizeof(*new_buffer)); // realloc may fail anyway
snprintf(new_buffer, new_size, "%s%s", buffer, commit_string);
free(buffer);
buffer = new_buffer;
@@ -333,7 +333,7 @@ int main(int argc, char **argv) {
}
}
- buffer = calloc(1, sizeof(char));
+ buffer = calloc(1, sizeof(*buffer));
display = wl_display_connect(NULL);
if (display == NULL) {
diff --git a/examples/touch.c b/examples/touch.c
index f32b5bba..53def624 100644
--- a/examples/touch.c
+++ b/examples/touch.c
@@ -104,7 +104,7 @@ static void touch_down_notify(struct wl_listener *listener, void *data) {
struct wlr_touch_down_event *event = data;
struct touch_state *tstate = wl_container_of(listener, tstate, down);
struct sample_state *sample = tstate->sample;
- struct touch_point *point = calloc(1, sizeof(struct touch_point));
+ struct touch_point *point = calloc(1, sizeof(*point));
point->touch_id = event->touch_id;
point->x = event->x;
point->y = event->y;
@@ -175,7 +175,7 @@ static void new_output_notify(struct wl_listener *listener, void *data) {
wlr_output_init_render(output, sample->allocator, sample->renderer);
- struct sample_output *sample_output = calloc(1, sizeof(struct sample_output));
+ struct sample_output *sample_output = calloc(1, sizeof(*sample_output));
sample_output->output = output;
sample_output->sample = sample;
wl_signal_add(&output->events.frame, &sample_output->frame);
@@ -222,7 +222,7 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
struct sample_state *sample = wl_container_of(listener, sample, new_input);
switch (device->type) {
case WLR_INPUT_DEVICE_KEYBOARD:;
- struct sample_keyboard *keyboard = calloc(1, sizeof(struct sample_keyboard));
+ struct sample_keyboard *keyboard = calloc(1, sizeof(*keyboard));
keyboard->wlr_keyboard = wlr_keyboard_from_input_device(device);
keyboard->sample = sample;
wl_signal_add(&device->events.destroy, &keyboard->destroy);
@@ -245,7 +245,7 @@ static void new_input_notify(struct wl_listener *listener, void *data) {
xkb_context_unref(context);
break;
case WLR_INPUT_DEVICE_TOUCH:;
- struct touch_state *tstate = calloc(sizeof(struct touch_state), 1);
+ struct touch_state *tstate = calloc(1, sizeof(*tstate));
tstate->wlr_touch = wlr_touch_from_input_device(device);
tstate->sample = sample;
tstate->destroy.notify = touch_destroy_notify;