summaryrefslogtreecommitdiff
path: root/src/utils.h
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2012-03-24 00:12:08 +0200
committerDaniel Stone <daniel@fooishbar.org>2012-03-27 14:12:34 +0100
commit3104a8ef181622805f39eba608523eec51591944 (patch)
treef2a707e73972133fde3ba3e6ad52702aa860d30c /src/utils.h
parent2a5f641657033e0ed1d4d9e712296e1e76bcaf6d (diff)
Move utility macro from XKBcommonint.h to utils.h
And merge all the similar ones into the same name. The u* prefix is chosen over the _Xkb prefix because it has more uses throughout the codebase. But It should now be simple to choose a nice prefix and stay consistent. Signed-off-by: Ran Benita <ran234@gmail.com> [daniels: fixed for the case where we have strcasecmp]
Diffstat (limited to 'src/utils.h')
-rw-r--r--src/utils.h22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/utils.h b/src/utils.h
index 2fbf87a..0b0582b 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -40,17 +40,21 @@
extern void *
recalloc(void *ptr, size_t old_size, size_t new_size);
-#define uTypedAlloc(t) ((t *)malloc((unsigned)sizeof(t)))
-#define uTypedCalloc(n,t) ((t *)calloc((unsigned)n,(unsigned)sizeof(t)))
-#define uTypedRealloc(pO,n,t) ((t *)realloc(pO,((unsigned)n)*sizeof(t)))
-#define uTypedRecalloc(pO, o, n, t) recalloc(pO, (o) * sizeof(t), (n) * sizeof(t))
+#define uTypedAlloc(t) malloc(sizeof(t))
+#define uTypedCalloc(n, t) calloc((n), sizeof(t))
+#define uTypedRealloc(pO, n, t) realloc((pO), (n) * sizeof(t))
+#define uTypedRecalloc(pO, o, n, t) recalloc((pO), (o) * sizeof(t), (n) * sizeof(t))
+
+#define uDupString(s) ((s) ? strdup(s) : NULL)
+#define uStringText(s) ((s) == NULL ? "<NullString>" : (s))
+#define uStrCaseCmp(s1, s2) strcasecmp(s1, s2)
+#define uStrCasePrefix(s1, s2) (strncasecmp((s1), (s2), strlen(s1)) == 0)
/***====================================================================***/
extern Bool
uSetErrorFile(char *name);
-
#define INFO uInformation
extern _X_ATTRIBUTE_PRINTF(1, 2) void
@@ -82,12 +86,4 @@ uFatalError(const char *s, ...);
extern _X_ATTRIBUTE_PRINTF(1, 2) void
uInternalError(const char *s, ...);
-/***====================================================================***/
-
-#define uStringText(s) ((s) == NULL ? "<NullString>" : (s))
-#define uStringEqual(s1,s2) (strcmp(s1,s2) == 0)
-#define uStringPrefix(p,s) (strncmp(p,s,strlen(p))==0)
-#define uStrCaseCmp(s1,s2) (strcasecmp(s1,s2))
-#define uStrCasePrefix(p,s) (strncasecmp(p,s,strlen(p))==0)
-
#endif /* UTILS_H */