aboutsummaryrefslogtreecommitdiffstats
path: root/src/util/util.c
diff options
context:
space:
mode:
authorFilip Wandzio <contact@philw.dev>2025-09-08 19:09:10 +0200
committerFilip Wandzio <contact@philw.dev>2025-09-08 19:09:10 +0200
commitf33c70176cd078c6e1c189b9c2a61089422129c9 (patch)
treeeaf3d27a81566d5118b0736ba32f5189963e4d1c /src/util/util.c
parentbd019ee25b380d32ccf900f5afa0dab9f9d541b8 (diff)
downloaddwm-f33c70176cd078c6e1c189b9c2a61089422129c9.tar.gz
dwm-f33c70176cd078c6e1c189b9c2a61089422129c9.zip
Enforce code style, reformat project
Signed-off-by: Filip Wandzio <contact@philw.dev>
Diffstat (limited to '')
-rw-r--r--src/util/util.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/util/util.c b/src/util/util.c
index 7419d0c..61c864c 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -18,19 +18,21 @@
18 * Usage: 18 * Usage:
19 * die("Error occurred in function %s", __func__); 19 * die("Error occurred in function %s", __func__);
20 */ 20 */
21void die(const char *format_string, ...) { 21void die(const char *format_string, ...)
22 va_list argument_list; 22{
23 va_start(argument_list, format_string); 23 va_list argument_list;
24 vfprintf(stderr, format_string, argument_list); 24 va_start(argument_list, format_string);
25 va_end(argument_list); 25 vfprintf(stderr, format_string, argument_list);
26 26 va_end(argument_list);
27 if (format_string[0] && format_string[strlen(format_string) - 1] == ':') { 27
28 fputc(' ', stderr); 28 if (format_string[0] &&
29 perror(NULL); 29 format_string[strlen(format_string) - 1] == ':') {
30 } else 30 fputc(' ', stderr);
31 fputc('\n', stderr); 31 perror(NULL);
32 32 } else
33 exit(1); 33 fputc('\n', stderr);
34
35 exit(1);
34} 36}
35 37
36/* 38/*
@@ -52,11 +54,12 @@ void die(const char *format_string, ...) {
52 * int *array = ecalloc(10, sizeof(int)); // Allocate memory for an array of 54 * int *array = ecalloc(10, sizeof(int)); // Allocate memory for an array of
53 * 10 integers. 55 * 10 integers.
54 */ 56 */
55void *ecalloc(size_t num_elements, size_t element_size) { 57void *ecalloc(size_t num_elements, size_t element_size)
56 void *allocated_memory; 58{
59 void *allocated_memory;
57 60
58 if (!(allocated_memory = calloc(num_elements, element_size))) 61 if (!(allocated_memory = calloc(num_elements, element_size)))
59 die("calloc:"); 62 die("calloc:");
60 63
61 return allocated_memory; 64 return allocated_memory;
62} 65}