chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
5f1be48
)
shared: inline trivial auto-cleanup functions
author
Michal Schmidt
<mschmidt@redhat.com>
Wed, 6 Mar 2013 13:44:51 +0000
(14:44 +0100)
committer
Michal Schmidt
<mschmidt@redhat.com>
Fri, 8 Mar 2013 09:09:31 +0000
(10:09 +0100)
src/shared/set.c
patch
|
blob
|
history
src/shared/set.h
patch
|
blob
|
history
src/shared/strv.c
patch
|
blob
|
history
src/shared/strv.h
patch
|
blob
|
history
src/shared/util.c
patch
|
blob
|
history
src/shared/util.h
patch
|
blob
|
history
diff --git
a/src/shared/set.c
b/src/shared/set.c
index 111d53bb36e6bd95d50348ddd03ed02e24d44a01..5f83c50839ae78b831d6f3853eea7ce6c6eb89a4 100644
(file)
--- a/
src/shared/set.c
+++ b/
src/shared/set.c
@@
-37,18
+37,10
@@
void set_free(Set* s) {
hashmap_free(MAKE_HASHMAP(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_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);
}
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);
}
diff --git
a/src/shared/set.h
b/src/shared/set.h
index 2f792585faea545d426c0cdce023a44b0f5adba4..38c4b58a80835a41e2bc3609b2be034a2545a460 100644
(file)
--- a/
src/shared/set.h
+++ b/
src/shared/set.h
@@
-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);
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_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);
Set* set_copy(Set *s);
int set_ensure_allocated(Set **s, hash_func_t hash_func, compare_func_t compare_func);
diff --git
a/src/shared/strv.c
b/src/shared/strv.c
index 117382ed80052d14620a744f269b827a3cfd9a27..7bcfabbf1a39d9901c74a830d372bbb505a8e13e 100644
(file)
--- a/
src/shared/strv.c
+++ b/
src/shared/strv.c
@@
-64,10
+64,6
@@
void strv_free(char **l) {
free(l);
}
free(l);
}
-void strv_freep(char ***l) {
- strv_free(*l);
-}
-
char **strv_copy(char **l) {
char **r, **k;
char **strv_copy(char **l) {
char **r, **k;
diff --git
a/src/shared/strv.h
b/src/shared/strv.h
index 623f10216dd8339f2d948f11d040022c5afd081c..da9fae6edb6d8c6450c582eda6dbf03036896ea6 100644
(file)
--- a/
src/shared/strv.h
+++ b/
src/shared/strv.h
@@
-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);
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);
char **strv_copy(char **l) _malloc_;
unsigned strv_length(char **l);
diff --git
a/src/shared/util.c
b/src/shared/util.c
index c493a34877eb7b2408d573bd155f93a4d98e5bcb..594f8de755c7a767b698187b50b67fe68e0d7185 100644
(file)
--- a/
src/shared/util.c
+++ b/
src/shared/util.c
@@
-5237,10
+5237,6
@@
int get_shell(char **_sh) {
return 0;
}
return 0;
}
-void freep(void *p) {
- free(*(void**) p);
-}
-
void fclosep(FILE **f) {
if (*f)
fclose(*f);
void fclosep(FILE **f) {
if (*f)
fclose(*f);
@@
-5261,10
+5257,6
@@
void closedirp(DIR **d) {
closedir(*d);
}
closedir(*d);
}
-void umaskp(mode_t *u) {
- umask(*u);
-}
-
bool filename_is_safe(const char *p) {
if (isempty(p))
bool filename_is_safe(const char *p) {
if (isempty(p))
diff --git
a/src/shared/util.h
b/src/shared/util.h
index 27b21f97cc4109da6e1e6bb0b3a7be8845f44103..04c9fcd71e4454830ce7a6f76595bcec1c9ec6d6 100644
(file)
--- a/
src/shared/util.h
+++ b/
src/shared/util.h
@@
-519,12
+519,17
@@
void warn_melody(void);
int get_shell(char **ret);
int get_home_dir(char **ret);
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 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))
_malloc_ static inline void *malloc_multiply(size_t a, size_t b) {
if (_unlikely_(b == 0 || a > ((size_t) -1) / b))