aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.h')
-rw-r--r--src/utils.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/utils.h b/src/utils.h
index 6a6e562cf..77e143702 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -76,6 +76,19 @@ mpd_malloc void *xrealloc(void *ptr, size_t size);
mpd_malloc void *xcalloc(size_t nmemb, size_t size);
+/**
+ * free a const pointer - unfortunately free() expects a non-const
+ * pointer, for whatever reason
+ */
+static inline void xfree(const void *p)
+{
+ union {
+ const void *in;
+ void *out;
+ } deconst = { .in = p };
+ free(deconst.out);
+}
+
char *parsePath(char *path);
int set_nonblocking(int fd);