diff --git a/daemon/aux.c b/daemon/aux.c index 5890e9d3a..34ed8d862 100644 --- a/daemon/aux.c +++ b/daemon/aux.c @@ -71,20 +71,6 @@ int pcre_multi_match(pcre *re, pcre_extra *ree, const char *s, unsigned int num, } -void strmove(char **d, char **s) { - if (*d) - free(*d); - *d = *s; - *s = strdup(""); -} - -void strdupfree(char **d, const char *s) { - if (*d) - free(*d); - *d = strdup(s); -} - - #if !GLIB_CHECK_VERSION(2,14,0) diff --git a/daemon/aux.h b/daemon/aux.h index 4ac21254a..31938b71b 100644 --- a/daemon/aux.h +++ b/daemon/aux.h @@ -47,8 +47,8 @@ typedef int (*parse_func)(char **, void **, void *); GList *g_list_link(GList *, GList *); int pcre_multi_match(pcre *, pcre_extra *, const char *, unsigned int, parse_func, void *, GQueue *); -void strmove(char **, char **); -void strdupfree(char **, const char *); +static inline void strmove(char **, char **); +static inline void strdupfree(char **, const char *); #if !GLIB_CHECK_VERSION(2,14,0) @@ -58,6 +58,20 @@ void g_queue_clear(GQueue *); #endif +static inline void strmove(char **d, char **s) { + if (*d) + free(*d); + *d = *s; + *s = strdup(""); +} + +static inline void strdupfree(char **d, const char *s) { + if (*d) + free(*d); + *d = strdup(s); +} + + static inline void nonblock(int fd) { fcntl(fd, F_SETFL, O_NONBLOCK); } @@ -162,10 +176,11 @@ static inline int smart_pton(int af, char *src, void *dst) { } static inline int strmemcmp(const void *mem, int len, const char *str) { - if (strlen(str) < len) - return 1; - if (strlen(str) > len) + int l = strlen(str); + if (l < len) return -1; + if (l > len) + return 1; return memcmp(mem, str, len); }