diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2013-06-04 12:53:32 -0400 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2013-06-04 12:53:32 -0400 |
commit | 6ca44589b07c2a809718c4a630005b999f53d58d (patch) | |
tree | 7a67c0c8237f8595d900e690f69cca8851e2dffd /src/libudev/util.h | |
parent | fcb3dc92650f0ab01816f258b5e521b5daab29a3 (diff) |
src/libudev/strv.{c,h}: bring in line with upstream
In doing so, we better alined util.{c,h} by movig the definitions
of freep, fclosep, closep, closedirp, umaskp from util.c to util.h
as static inline. We also add strv_env_get to env-util.{c,h} which
we forgot to do earlier.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/libudev/util.h')
-rw-r--r-- | src/libudev/util.h | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/src/libudev/util.h b/src/libudev/util.h index 6748076943..fc58943b38 100644 --- a/src/libudev/util.h +++ b/src/libudev/util.h @@ -553,7 +553,7 @@ char *format_bytes(char *buf, size_t l, off_t t); int fd_wait_for_event(int fd, int event, usec_t timeout); -void* memdup(const void *p, size_t l) _malloc_; +void* memdup(const void *p, size_t l) _alloc_(2); int is_kernel_thread(pid_t pid); @@ -575,14 +575,35 @@ bool in_initrd(void); void warn_melody(void); -int get_shell(char **ret); int get_home_dir(char **ret); -void freep(void *p); -void fclosep(FILE **f); -void closep(int *fd); -void closedirp(DIR **d); -void umaskp(mode_t *u); +static inline void freep(void *p) { + free(*(void**) p); +} + +static inline void fclosep(FILE **f) { + if (*f) + fclose(*f); +} + +static inline void pclosep(FILE **f) { + if (*f) + pclose(*f); +} + +static inline void closep(int *fd) { + if (*fd >= 0) + close_nointr_nofail(*fd); +} + +static inline void closedirp(DIR **d) { + if (*d) + closedir(*d); +} + +static inline void umaskp(mode_t *u) { + umask(*u); +} #define _cleanup_free_ _cleanup_(freep) #define _cleanup_fclose_ _cleanup_(fclosep) |