summaryrefslogtreecommitdiff
path: root/app/xkbcomp/utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'app/xkbcomp/utils.h')
-rw-r--r--app/xkbcomp/utils.h89
1 files changed, 26 insertions, 63 deletions
diff --git a/app/xkbcomp/utils.h b/app/xkbcomp/utils.h
index 728d7b4e1..2bf767447 100644
--- a/app/xkbcomp/utils.h
+++ b/app/xkbcomp/utils.h
@@ -29,15 +29,17 @@
/***====================================================================***/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdio.h>
+#include <stdlib.h>
#include <X11/Xos.h>
#include <X11/Xfuncproto.h>
#include <X11/Xfuncs.h>
#include <stddef.h>
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
#ifndef NUL
#define NUL '\0'
@@ -45,13 +47,6 @@
/***====================================================================***/
-#ifndef OPAQUE_DEFINED
-typedef void *Opaque;
-#endif
-#ifndef NullOpaque
-#define NullOpaque ((Opaque)NULL)
-#endif
-
#ifndef BOOLEAN_DEFINED
typedef char Boolean;
#endif
@@ -74,37 +69,23 @@ typedef int Comparison;
/***====================================================================***/
-extern Opaque uAlloc(unsigned /* size */
- );
-extern Opaque uCalloc(unsigned /* n */ ,
- unsigned /* size */
- );
-extern Opaque uRealloc(Opaque /* old */ ,
- unsigned /* newSize */
- );
-extern Opaque uRecalloc(Opaque /* old */ ,
- unsigned /* nOld */ ,
- unsigned /* nNew */ ,
- unsigned /* newSize */
- );
-extern void uFree(Opaque /* ptr */
- );
+#ifndef HAVE_REALLOCARRAY
+#define reallocarray(p, n, s) realloc(p, (n) * (s))
+#endif
-#define uTypedAlloc(t) ((t *)uAlloc((unsigned)sizeof(t)))
-#define uTypedCalloc(n,t) ((t *)uCalloc((unsigned)n,(unsigned)sizeof(t)))
-#define uTypedRealloc(pO,n,t) ((t *)uRealloc((Opaque)pO,((unsigned)n)*sizeof(t)))
-#define uTypedRecalloc(pO,o,n,t) ((t *)uRecalloc((Opaque)pO,((unsigned)o),((unsigned)n),sizeof(t)))
-#if (defined mdHasAlloca) && (mdHasAlloca)
-#define uTmpAlloc(n) ((Opaque)alloca((unsigned)n))
-#define uTmpFree(p)
-#else
-#define uTmpAlloc(n) uAlloc(n)
-#define uTmpFree(p) uFree(p)
+#ifndef HAVE_RECALLOCARRAY
+#define recallocarray uRecalloc
+
+extern void *uRecalloc(void * /* old */ ,
+ size_t /* nOld */ ,
+ size_t /* nNew */ ,
+ size_t /* newSize */
+ );
#endif
/***====================================================================***/
-extern Boolean uSetErrorFile(char * /* name */
+extern Boolean uSetErrorFile(const char * /* name */
);
#define INFO uInformation
@@ -139,13 +120,13 @@ uInformation(const char * /* s */ , ...
extern void uInternalError(const char * /* s */ , ...
) _X_ATTRIBUTE_PRINTF(1, 2);
- extern void uSetPreErrorMessage(char * /* msg */
+ extern void uSetPreErrorMessage(const char * /* msg */
);
- extern void uSetPostErrorMessage(char * /* msg */
+ extern void uSetPostErrorMessage(const char * /* msg */
);
- extern void uSetErrorPrefix(char * /* void */
+ extern void uSetErrorPrefix(const char * /* void */
);
extern void uFinishUp(void);
@@ -183,40 +164,28 @@ uInformation(const char * /* s */ , ...
/***====================================================================***/
+#ifdef DEBUG
#ifndef DEBUG_VAR
#define DEBUG_VAR debugFlags
#endif
-extern
- unsigned int DEBUG_VAR;
+extern unsigned int DEBUG_VAR;
- extern void uDebug(char * /* s */ , ...
- ) _X_ATTRIBUTE_PRINTF(1, 2);
+extern void uDebug(const char *, ...) _X_ATTRIBUTE_PRINTF(1, 2);
- extern void uDebugNOI( /* no indent */
- char * /* s */ , ...
- ) _X_ATTRIBUTE_PRINTF(1, 2);
+extern Boolean uSetDebugFile(const char *name);
- extern Boolean uSetDebugFile(char *name);
+extern int uDebugIndentLevel;
- extern FILE *uDebugFile;
- extern int uDebugIndentLevel;
- extern int uDebugIndentSize;
#define uDebugIndent(l) (uDebugIndentLevel+=(l))
#define uDebugOutdent(l) (uDebugIndentLevel-=(l))
-#ifdef DEBUG
+
#define uDEBUG(f,s) { if (DEBUG_VAR&(f)) uDebug(s);}
#define uDEBUG1(f,s,a) { if (DEBUG_VAR&(f)) uDebug(s,a);}
#define uDEBUG2(f,s,a,b) { if (DEBUG_VAR&(f)) uDebug(s,a,b);}
#define uDEBUG3(f,s,a,b,c) { if (DEBUG_VAR&(f)) uDebug(s,a,b,c);}
#define uDEBUG4(f,s,a,b,c,d) { if (DEBUG_VAR&(f)) uDebug(s,a,b,c,d);}
#define uDEBUG5(f,s,a,b,c,d,e) { if (DEBUG_VAR&(f)) uDebug(s,a,b,c,d,e);}
-#define uDEBUG_NOI(f,s) { if (DEBUG_VAR&(f)) uDebug(s);}
-#define uDEBUG_NOI1(f,s,a) { if (DEBUG_VAR&(f)) uDebugNOI(s,a);}
-#define uDEBUG_NOI2(f,s,a,b) { if (DEBUG_VAR&(f)) uDebugNOI(s,a,b);}
-#define uDEBUG_NOI3(f,s,a,b,c) { if (DEBUG_VAR&(f)) uDebugNOI(s,a,b,c);}
-#define uDEBUG_NOI4(f,s,a,b,c,d) { if (DEBUG_VAR&(f)) uDebugNOI(s,a,b,c,d);}
-#define uDEBUG_NOI5(f,s,a,b,c,d,e) { if (DEBUG_VAR&(f)) uDebugNOI(s,a,b,c,d,e);}
#else
#define uDEBUG(f,s)
#define uDEBUG1(f,s,a)
@@ -224,12 +193,6 @@ extern
#define uDEBUG3(f,s,a,b,c)
#define uDEBUG4(f,s,a,b,c,d)
#define uDEBUG5(f,s,a,b,c,d,e)
-#define uDEBUG_NOI(f,s)
-#define uDEBUG_NOI1(f,s,a)
-#define uDEBUG_NOI2(f,s,a,b)
-#define uDEBUG_NOI3(f,s,a,b,c)
-#define uDEBUG_NOI4(f,s,a,b,c,d)
-#define uDEBUG_NOI5(f,s,a,b,c,d,e)
#endif
#endif /* UTILS_H */