From 94d531fd827457cf71fe7f3808c7a2f531dceba5 Mon Sep 17 00:00:00 2001 From: NRK Date: Sat, 30 Jul 2022 10:05:10 +0200 Subject: autoreload: simplify and cleanup (#342) the current code is quite hacky and complex as it mixes multiple pointers. all of this complexity is unnecessary. drop it by introducing an explicit scratch buffer instead of implicitly abusing `arl->filename` as one. this also reduces some unnecessary allocation overhead. additionally, the argument to arl_setup must be the result of `realpath(3)` (as commented in `nsxiv.h`). instead of commenting it, assert it. and lastly, rename `arl_setup` to `arl_add` since it's not doing any "setup" but rather *adding* a file to watch. Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/342 Reviewed-by: explosion-mental --- nsxiv.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'nsxiv.h') diff --git a/nsxiv.h b/nsxiv.h index 4f903e9..7262e1e 100644 --- a/nsxiv.h +++ b/nsxiv.h @@ -124,12 +124,12 @@ struct arl { int fd; int wd_dir; int wd_file; - char *filename; + const char *filename; }; void arl_init(arl_t*); void arl_cleanup(arl_t*); -void arl_setup(arl_t*, const char* /* result of realpath(3) */); +void arl_add(arl_t*, const char* /* result of realpath(3) */); bool arl_handle(arl_t*); -- cgit v1.2.3-54-g00ecf