diff options
author | Simon Ser <contact@emersion.fr> | 2022-04-21 11:48:49 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-05-23 08:59:05 +0000 |
commit | 963014459c5eb54b1317c688f9e2dfbac44a672d (patch) | |
tree | 3d4dc70ece15768a7fd9e83a201a7271f40133be | |
parent | bcfcd49232e3881d995da83a15dbc2897148c5fb (diff) |
cursor: convert macros to functions
Improves readability since there's no need for so many parentheses
anymore, adds type safety. The compiler will inline the function
automatically as necessary.
Signed-off-by: Simon Ser <contact@emersion.fr>
-rw-r--r-- | cursor/xcursor.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/cursor/xcursor.c b/cursor/xcursor.c index e4b9a9d..0a7dfec 100644 --- a/cursor/xcursor.c +++ b/cursor/xcursor.c @@ -379,7 +379,11 @@ xcursor_file_read_chunk_header(struct xcursor_file *file, return true; } -#define dist(a,b) ((a) > (b) ? (a) - (b) : (b) - (a)) +static uint32_t +dist(uint32_t a, uint32_t b) +{ + return a > b ? a - b : b - a; +} static uint32_t xcursor_file_best_size(struct xcursor_file_header *fileHeader, @@ -728,8 +732,17 @@ xcursor_next_path(const char *path) return colon + 1; } -#define xcursor_white(c) ((c) == ' ' || (c) == '\t' || (c) == '\n') -#define xcursor_sep(c) ((c) == ';' || (c) == ',') +static bool +xcursor_white(char c) +{ + return c == ' ' || c == '\t' || c == '\n'; +} + +static bool +xcursor_sep(char c) +{ + return c == ';' || c == ','; +} static char * xcursor_theme_inherits(const char *full) |