mirror of
https://github.com/systemd/systemd.git
synced 2025-03-08 08:58:27 +03:00
fd-util: Close function for FD_TO_PTR
Just a function to be used as a destructor (i.e. in a _cleanup_ attribute, hash table operations, etc.) that closes an fd wrapped in FD_TO_PTR It just retrieves the fd via PTR_TO_FD and closes it
This commit is contained in:
parent
f0409e7b42
commit
a1bdae3645
@ -52,6 +52,11 @@ static inline void fclosep(FILE **f) {
|
||||
safe_fclose(*f);
|
||||
}
|
||||
|
||||
static inline void* close_fd_ptr(void *p) {
|
||||
safe_close(PTR_TO_FD(p));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(FILE*, pclose, NULL);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(DIR*, closedir, NULL);
|
||||
|
||||
|
@ -33,11 +33,6 @@ static TunTap* TUNTAP(NetDev *netdev) {
|
||||
}
|
||||
}
|
||||
|
||||
static void *close_fd_ptr(void *p) {
|
||||
safe_close(PTR_TO_FD(p));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEFINE_PRIVATE_HASH_OPS_FULL(named_fd_hash_ops, char, string_hash_func, string_compare_func, free, void, close_fd_ptr);
|
||||
|
||||
int manager_add_tuntap_fd(Manager *m, int fd, const char *name) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user