Implement strdupnull() macro as static inline function.

This avoids compiler warnings if the argument is a const char*.
This commit is contained in:
Tobias Brunner
2012-06-11 17:33:30 +02:00
parent 7cce0e96f2
commit 753ca22f9c
+4 -1
View File
@@ -74,7 +74,10 @@
/** /**
* NULL-safe strdup variant * NULL-safe strdup variant
*/ */
#define strdupnull(x) ({ char *_x = x; _x ? strdup(_x) : NULL; }) static inline char *strdupnull(const char *s)
{
return s ? strdup(s) : NULL;
}
/** /**
* Macro compares two binary blobs for equality * Macro compares two binary blobs for equality