shared: inline trivial auto-cleanup functions
This commit is contained in:
parent
5f1be48b26
commit
a740c14c59
|
@ -37,18 +37,10 @@ void set_free(Set* s) {
|
|||
hashmap_free(MAKE_HASHMAP(s));
|
||||
}
|
||||
|
||||
void set_freep(Set **s) {
|
||||
set_free(*s);
|
||||
}
|
||||
|
||||
void set_free_free(Set *s) {
|
||||
hashmap_free_free(MAKE_HASHMAP(s));
|
||||
}
|
||||
|
||||
void set_free_freep(Set **s) {
|
||||
set_free_free(*s);
|
||||
}
|
||||
|
||||
int set_ensure_allocated(Set **s, hash_func_t hash_func, compare_func_t compare_func) {
|
||||
return hashmap_ensure_allocated((Hashmap**) s, hash_func, compare_func);
|
||||
}
|
||||
|
|
|
@ -33,9 +33,15 @@ typedef struct Set Set;
|
|||
|
||||
Set *set_new(hash_func_t hash_func, compare_func_t compare_func);
|
||||
void set_free(Set* s);
|
||||
void set_freep(Set **s);
|
||||
static inline void set_freep(Set **s) {
|
||||
set_free(*s);
|
||||
}
|
||||
|
||||
void set_free_free(Set *s);
|
||||
void set_free_freep(Set **s);
|
||||
static inline void set_free_freep(Set **s) {
|
||||
set_free_free(*s);
|
||||
}
|
||||
|
||||
Set* set_copy(Set *s);
|
||||
int set_ensure_allocated(Set **s, hash_func_t hash_func, compare_func_t compare_func);
|
||||
|
||||
|
|
|
@ -64,10 +64,6 @@ void strv_free(char **l) {
|
|||
free(l);
|
||||
}
|
||||
|
||||
void strv_freep(char ***l) {
|
||||
strv_free(*l);
|
||||
}
|
||||
|
||||
char **strv_copy(char **l) {
|
||||
char **r, **k;
|
||||
|
||||
|
|
|
@ -30,7 +30,10 @@ char *strv_find(char **l, const char *name);
|
|||
char *strv_find_prefix(char **l, const char *name);
|
||||
|
||||
void strv_free(char **l);
|
||||
void strv_freep(char ***l);
|
||||
static inline void strv_freep(char ***l) {
|
||||
strv_free(*l);
|
||||
}
|
||||
|
||||
char **strv_copy(char **l) _malloc_;
|
||||
unsigned strv_length(char **l);
|
||||
|
||||
|
|
|
@ -5237,10 +5237,6 @@ int get_shell(char **_sh) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void freep(void *p) {
|
||||
free(*(void**) p);
|
||||
}
|
||||
|
||||
void fclosep(FILE **f) {
|
||||
if (*f)
|
||||
fclose(*f);
|
||||
|
@ -5261,10 +5257,6 @@ void closedirp(DIR **d) {
|
|||
closedir(*d);
|
||||
}
|
||||
|
||||
void umaskp(mode_t *u) {
|
||||
umask(*u);
|
||||
}
|
||||
|
||||
bool filename_is_safe(const char *p) {
|
||||
|
||||
if (isempty(p))
|
||||
|
|
|
@ -519,12 +519,17 @@ void warn_melody(void);
|
|||
int get_shell(char **ret);
|
||||
int get_home_dir(char **ret);
|
||||
|
||||
void freep(void *p);
|
||||
static inline void freep(void *p) {
|
||||
free(*(void**) p);
|
||||
}
|
||||
|
||||
void fclosep(FILE **f);
|
||||
void pclosep(FILE **f);
|
||||
void closep(int *fd);
|
||||
void closedirp(DIR **d);
|
||||
void umaskp(mode_t *u);
|
||||
static inline void umaskp(mode_t *u) {
|
||||
umask(*u);
|
||||
}
|
||||
|
||||
_malloc_ static inline void *malloc_multiply(size_t a, size_t b) {
|
||||
if (_unlikely_(b == 0 || a > ((size_t) -1) / b))
|
||||
|
|
Loading…
Reference in a new issue