Move utility macro from XKBcommonint.h to utils.h
authorRan Benita <ran234@gmail.com>
Fri, 23 Mar 2012 22:12:08 +0000 (00:12 +0200)
committerDaniel Stone <daniel@fooishbar.org>
Tue, 27 Mar 2012 13:12:34 +0000 (14:12 +0100)
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]

14 files changed:
src/XKBcommonint.h
src/alloc.c
src/malloc.c
src/map.c
src/maprules.c
src/utils.h
src/xkbcomp/compat.c
src/xkbcomp/indicators.c
src/xkbcomp/keycodes.c
src/xkbcomp/keytypes.c
src/xkbcomp/parseutils.c
src/xkbcomp/symbols.c
src/xkbcomp/xkbcomp.c
src/xkbcomp/xkbpath.c

index 3205a01..f900a69 100644 (file)
@@ -89,15 +89,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #define False 0
 #endif
 
-#define _XkbTypedAlloc(t)       ((t *)malloc(sizeof(t)))
-#define _XkbTypedCalloc(n,t)    ((t *)calloc((n),sizeof(t)))
-#define _XkbTypedRealloc(o,n,t) \
-    ((o)?(t *)realloc((o),(n)*sizeof(t)):_XkbTypedCalloc(n,t))
-#define _XkbClearElems(a,f,l,t) memset(&(a)[f], 0, ((l) - (f) + 1) * sizeof(t))
-
-#define _XkbDupString(s)        ((s) ? strdup(s) : NULL)
-#define _XkbStrCaseCmp          strcasecmp
-
 /* From XKM.h */
 #define        XkmFileVersion          15
 
index 8dd4b5f..1a46fbb 100644 (file)
@@ -26,6 +26,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "utils.h"
 #include "xkballoc.h"
 #include "xkbcommon/xkbcommon.h"
 #include "XKBcommonint.h"
@@ -50,27 +51,24 @@ XkbcAllocCompatMap(struct xkb_desc * xkb, unsigned which, unsigned nSI)
             compat->num_si = 0;
 
         prev_interpret = compat->sym_interpret;
-        compat->sym_interpret = _XkbTypedRealloc(compat->sym_interpret,
-                                                 nSI, struct xkb_sym_interpret);
+        compat->sym_interpret = uTypedRecalloc(compat->sym_interpret,
+                                               compat->num_si, nSI,
+                                               struct xkb_sym_interpret);
         if (!compat->sym_interpret) {
             free(prev_interpret);
             compat->size_si = compat->num_si = 0;
             return BadAlloc;
         }
 
-        if (compat->num_si != 0)
-            _XkbClearElems(compat->sym_interpret, compat->num_si,
-                           compat->size_si - 1, struct xkb_sym_interpret);
-
         return Success;
     }
 
-    compat = _XkbTypedCalloc(1, struct xkb_compat_map);
+    compat = uTypedCalloc(1, struct xkb_compat_map);
     if (!compat)
         return BadAlloc;
 
     if (nSI > 0) {
-        compat->sym_interpret = _XkbTypedCalloc(nSI, struct xkb_sym_interpret);
+        compat->sym_interpret = uTypedCalloc(nSI, struct xkb_sym_interpret);
         if (!compat->sym_interpret) {
             free(compat);
             return BadAlloc;
@@ -109,7 +107,7 @@ XkbcAllocNames(struct xkb_desc * xkb, unsigned which, int nTotalAliases)
         return BadMatch;
 
     if (!xkb->names) {
-        xkb->names = _XkbTypedCalloc(1, struct xkb_names);
+        xkb->names = uTypedCalloc(1, struct xkb_names);
         if (!xkb->names)
             return BadAlloc;
     }
@@ -122,7 +120,7 @@ XkbcAllocNames(struct xkb_desc * xkb, unsigned which, int nTotalAliases)
         type = xkb->map->types;
         for (i = 0; i < xkb->map->num_types; i++, type++) {
             if (!type->level_names) {
-                type->level_names = _XkbTypedCalloc(type->num_levels, const char *);
+                type->level_names = uTypedCalloc(type->num_levels, const char *);
                 if (!type->level_names)
                     return BadAlloc;
             }
@@ -133,25 +131,23 @@ XkbcAllocNames(struct xkb_desc * xkb, unsigned which, int nTotalAliases)
         if (!xkb_keymap_keycode_range_is_legal(xkb))
             return BadMatch;
 
-        names->keys = _XkbTypedCalloc(xkb->max_key_code + 1, struct xkb_key_name);
+        names->keys = uTypedCalloc(xkb->max_key_code + 1, struct xkb_key_name);
         if (!names->keys)
             return BadAlloc;
     }
 
     if ((which & XkbKeyAliasesMask) && (nTotalAliases > 0)) {
         if (!names->key_aliases)
-            names->key_aliases = _XkbTypedCalloc(nTotalAliases,
+            names->key_aliases = uTypedCalloc(nTotalAliases,
                                                  struct xkb_key_alias);
         else if (nTotalAliases > names->num_key_aliases) {
             struct xkb_key_alias *prev_aliases = names->key_aliases;
 
-            names->key_aliases = _XkbTypedRealloc(names->key_aliases,
-                                                  nTotalAliases,
-                                                  struct xkb_key_alias);
-            if (names->key_aliases)
-                _XkbClearElems(names->key_aliases, names->num_key_aliases,
-                               nTotalAliases - 1, struct xkb_key_alias);
-            else
+            names->key_aliases = uTypedRecalloc(names->key_aliases,
+                                                names->num_key_aliases,
+                                                nTotalAliases,
+                                                struct xkb_key_alias);
+            if (!names->key_aliases)
                 free(prev_aliases);
         }
 
@@ -211,14 +207,14 @@ XkbcAllocControls(struct xkb_desc * xkb, unsigned which)
         return BadMatch;
 
     if (!xkb->ctrls) {
-        xkb->ctrls = _XkbTypedCalloc(1, struct xkb_controls);
+        xkb->ctrls = uTypedCalloc(1, struct xkb_controls);
         if (!xkb->ctrls)
             return BadAlloc;
     }
 
     if (!xkb->ctrls->per_key_repeat) {
-        xkb->ctrls->per_key_repeat = _XkbTypedCalloc(xkb->max_key_code << 3,
-                                                     unsigned char);
+        xkb->ctrls->per_key_repeat = uTypedCalloc(xkb->max_key_code << 3,
+                                                  unsigned char);
         if (!xkb->ctrls->per_key_repeat)
             return BadAlloc;
     }
@@ -243,7 +239,7 @@ XkbcAllocIndicatorMaps(struct xkb_desc * xkb)
         return BadMatch;
 
     if (!xkb->indicators) {
-        xkb->indicators = _XkbTypedCalloc(1, struct xkb_indicator);
+        xkb->indicators = uTypedCalloc(1, struct xkb_indicator);
         if (!xkb->indicators)
             return BadAlloc;
     }
@@ -265,7 +261,7 @@ XkbcAllocKeyboard(void)
 {
     struct xkb_desc *xkb;
 
-    xkb = _XkbTypedCalloc(1, struct xkb_desc);
+    xkb = uTypedCalloc(1, struct xkb_desc);
     if (xkb) {
         xkb->device_spec = XkbUseCoreKbd;
         xkb->refcnt = 1;
index 40f0f7b..cff30d7 100644 (file)
@@ -24,6 +24,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 ********************************************************/
 
+#include "utils.h"
 #include "xkballoc.h"
 #include "xkbcommon/xkbcommon.h"
 #include "XKBcommonint.h"
@@ -46,7 +47,7 @@ XkbcAllocClientMap(struct xkb_desc * xkb, unsigned which, unsigned nTotalTypes)
     }
 
     if (!xkb->map) {
-        map = _XkbTypedCalloc(1, struct xkb_client_map);
+        map = uTypedCalloc(1, struct xkb_client_map);
         if (!map)
             return BadAlloc;
         xkb->map = map;
@@ -56,7 +57,7 @@ XkbcAllocClientMap(struct xkb_desc * xkb, unsigned which, unsigned nTotalTypes)
 
     if ((which & XkbKeyTypesMask) && (nTotalTypes > 0)) {
         if (!map->types) {
-            map->types = _XkbTypedCalloc(nTotalTypes, struct xkb_key_type);
+            map->types = uTypedCalloc(nTotalTypes, struct xkb_key_type);
             if (!map->types)
                 return BadAlloc;
 
@@ -66,7 +67,7 @@ XkbcAllocClientMap(struct xkb_desc * xkb, unsigned which, unsigned nTotalTypes)
         else if (map->size_types < nTotalTypes) {
             struct xkb_key_type *prev_types = map->types;
 
-            map->types = _XkbTypedRealloc(map->types, nTotalTypes,
+            map->types = uTypedRealloc(map->types, nTotalTypes,
                                           struct xkb_key_type);
             if (!map->types) {
                 free(prev_types);
@@ -85,7 +86,7 @@ XkbcAllocClientMap(struct xkb_desc * xkb, unsigned which, unsigned nTotalTypes)
 
         if (!map->syms) {
             map->size_syms = (nKeys * 15) / 10;
-            map->syms = _XkbTypedCalloc(map->size_syms, xkb_keysym_t);
+            map->syms = uTypedCalloc(map->size_syms, xkb_keysym_t);
             if (!map->syms) {
                 map->size_syms = 0;
                 return BadAlloc;
@@ -96,7 +97,7 @@ XkbcAllocClientMap(struct xkb_desc * xkb, unsigned which, unsigned nTotalTypes)
 
         if (!map->key_sym_map) {
             i = xkb->max_key_code + 1;
-            map->key_sym_map = _XkbTypedCalloc(i, struct xkb_sym_map);
+            map->key_sym_map = uTypedCalloc(i, struct xkb_sym_map);
             if (!map->key_sym_map)
                 return BadAlloc;
         }
@@ -108,7 +109,7 @@ XkbcAllocClientMap(struct xkb_desc * xkb, unsigned which, unsigned nTotalTypes)
 
         if (!map->modmap) {
             i = xkb->max_key_code + 1;
-            map->modmap = _XkbTypedCalloc(i, unsigned char);
+            map->modmap = uTypedCalloc(i, unsigned char);
             if (!map->modmap)
                 return BadAlloc;
         }
@@ -127,7 +128,7 @@ XkbcAllocServerMap(struct xkb_desc * xkb, unsigned which, unsigned nNewActions)
         return BadMatch;
 
     if (!xkb->server) {
-        map = _XkbTypedCalloc(1, struct xkb_server_map);
+        map = uTypedCalloc(1, struct xkb_server_map);
         if (!map)
             return BadAlloc;
 
@@ -148,7 +149,7 @@ XkbcAllocServerMap(struct xkb_desc * xkb, unsigned which, unsigned nNewActions)
     if (which & XkbExplicitComponentsMask) {
         if (!map->explicit) {
             i = xkb->max_key_code + 1;
-            map->explicit = _XkbTypedCalloc(i, unsigned char);
+            map->explicit = uTypedCalloc(i, unsigned char);
             if (!map->explicit)
                 return BadAlloc;
         }
@@ -159,7 +160,7 @@ XkbcAllocServerMap(struct xkb_desc * xkb, unsigned which, unsigned nNewActions)
             nNewActions = 1;
 
         if (!map->acts) {
-            map->acts = _XkbTypedCalloc(nNewActions + 1, union xkb_action);
+            map->acts = uTypedCalloc(nNewActions + 1, union xkb_action);
             if (!map->acts)
                 return BadAlloc;
             map->num_acts = 1;
@@ -170,7 +171,7 @@ XkbcAllocServerMap(struct xkb_desc * xkb, unsigned which, unsigned nNewActions)
             union xkb_action *prev_acts = map->acts;
 
             need = map->num_acts + nNewActions;
-            map->acts = _XkbTypedRealloc(map->acts, need, union xkb_action);
+            map->acts = uTypedRealloc(map->acts, need, union xkb_action);
             if (!map->acts) {
                 free(prev_acts);
                 map->num_acts = map->size_acts = 0;
@@ -184,7 +185,7 @@ XkbcAllocServerMap(struct xkb_desc * xkb, unsigned which, unsigned nNewActions)
 
         if (!map->key_acts) {
             i = xkb->max_key_code + 1;
-            map->key_acts = _XkbTypedCalloc(i, unsigned short);
+            map->key_acts = uTypedCalloc(i, unsigned short);
             if (!map->key_acts)
                 return BadAlloc;
         }
@@ -193,7 +194,7 @@ XkbcAllocServerMap(struct xkb_desc * xkb, unsigned which, unsigned nNewActions)
     if (which & XkbKeyBehaviorsMask) {
         if (!map->behaviors) {
             i = xkb->max_key_code + 1;
-            map->behaviors = _XkbTypedCalloc(i, struct xkb_behavior);
+            map->behaviors = uTypedCalloc(i, struct xkb_behavior);
             if (!map->behaviors)
                 return BadAlloc;
         }
@@ -202,7 +203,7 @@ XkbcAllocServerMap(struct xkb_desc * xkb, unsigned which, unsigned nNewActions)
     if (which & XkbVirtualModMapMask) {
         if (!map->vmodmap) {
             i = xkb->max_key_code + 1;
-            map->vmodmap = _XkbTypedCalloc(i, uint32_t);
+            map->vmodmap = uTypedCalloc(i, uint32_t);
             if (!map->vmodmap)
                 return BadAlloc;
         }
@@ -231,7 +232,7 @@ XkbcCopyKeyType(struct xkb_key_type * from, struct xkb_key_type * into)
     *into = *from;
 
     if (from->map && (into->map_count > 0)) {
-        into->map = _XkbTypedCalloc(into->map_count, struct xkb_kt_map_entry);
+        into->map = uTypedCalloc(into->map_count, struct xkb_kt_map_entry);
         if (!into->map)
             return BadAlloc;
         memcpy(into->map, from->map,
@@ -239,7 +240,7 @@ XkbcCopyKeyType(struct xkb_key_type * from, struct xkb_key_type * into)
     }
 
     if (from->preserve && (into->map_count > 0)) {
-        into->preserve = _XkbTypedCalloc(into->map_count, struct xkb_mods);
+        into->preserve = uTypedCalloc(into->map_count, struct xkb_mods);
         if (!into->preserve)
             return BadAlloc;
         memcpy(into->preserve, from->preserve,
@@ -247,7 +248,7 @@ XkbcCopyKeyType(struct xkb_key_type * from, struct xkb_key_type * into)
     }
 
     if (from->level_names && (into->num_levels > 0)) {
-        into->level_names = _XkbTypedCalloc(into->num_levels, const char *);
+        into->level_names = uTypedCalloc(into->num_levels, const char *);
         if (!into->level_names)
             return BadAlloc;
         for (i = 0; i < into->num_levels; i++)
@@ -290,7 +291,7 @@ XkbcResizeKeySyms(struct xkb_desc * xkb, xkb_keycode_t key,
     }
 
     xkb->map->size_syms += (needed > 32 ? needed : 32);
-    newSyms = _XkbTypedCalloc(xkb->map->size_syms, xkb_keysym_t);
+    newSyms = uTypedCalloc(xkb->map->size_syms, xkb_keysym_t);
     if (!newSyms)
         return NULL;
 
@@ -346,7 +347,7 @@ XkbcResizeKeyActions(struct xkb_desc * xkb, xkb_keycode_t key, int needed)
     }
 
     xkb->server->size_acts = xkb->server->num_acts + needed + 8;
-    newActs = _XkbTypedCalloc(xkb->server->size_acts, union xkb_action);
+    newActs = uTypedCalloc(xkb->server->size_acts, union xkb_action);
     if (!newActs)
         return NULL;
     newActs[0].type = XkbSA_NoAction;
index 7f1d85a..ece711f 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -53,6 +53,7 @@
 #include <config.h>
 #endif
 
+#include "utils.h"
 #include "xkbcommon/xkbcommon.h"
 #include "XKBcommonint.h"
 #include "xkballoc.h"
index dfb32e1..80e2cb3 100644 (file)
@@ -27,6 +27,7 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include "utils.h"
 #include "xkbrules.h"
 #include "xkbcommon/xkbcommon.h"
 #include "XKBcommonint.h"
@@ -407,8 +408,8 @@ CheckLine(  InputLine *             line,
             }
             if (*words == '\0')
                 return False;
-            group->name = _XkbDupString(gname);
-            group->words = _XkbDupString(words);
+            group->name = uDupString(gname);
+            group->words = uDupString(words);
             for (i = 1, words = group->words; *words; words++) {
                  if ( *words == ' ') {
                      *words++ = '\0';
@@ -459,16 +460,16 @@ CheckLine(        InputLine *             line,
         rule->flags|= XkbRF_Append;
     else
         rule->flags|= XkbRF_Normal;
-    rule->model= _XkbDupString(tmp.name[MODEL]);
-    rule->layout= _XkbDupString(tmp.name[LAYOUT]);
-    rule->variant= _XkbDupString(tmp.name[VARIANT]);
-    rule->option= _XkbDupString(tmp.name[OPTION]);
+    rule->model= uDupString(tmp.name[MODEL]);
+    rule->layout= uDupString(tmp.name[LAYOUT]);
+    rule->variant= uDupString(tmp.name[VARIANT]);
+    rule->option= uDupString(tmp.name[OPTION]);
 
-    rule->keycodes= _XkbDupString(tmp.name[KEYCODES]);
-    rule->symbols= _XkbDupString(tmp.name[SYMBOLS]);
-    rule->types= _XkbDupString(tmp.name[TYPES]);
-    rule->compat= _XkbDupString(tmp.name[COMPAT]);
-    rule->keymap= _XkbDupString(tmp.name[KEYMAP]);
+    rule->keycodes= uDupString(tmp.name[KEYCODES]);
+    rule->symbols= uDupString(tmp.name[SYMBOLS]);
+    rule->types= uDupString(tmp.name[TYPES]);
+    rule->compat= uDupString(tmp.name[COMPAT]);
+    rule->keymap= uDupString(tmp.name[KEYMAP]);
 
     rule->layout_num = rule->variant_num = 0;
     for (i = 0; i < nread; i++) {
@@ -490,7 +491,7 @@ _Concat(char *str1,char *str2)
     if ((!str1)||(!str2))
        return str1;
     len= strlen(str1)+strlen(str2)+1;
-    str1= _XkbTypedRealloc(str1,len,char);
+    str1 = uTypedRealloc(str1, len, char);
     if (str1)
        strcat(str1,str2);
     return str1;
@@ -512,7 +513,7 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
 {
    memset(mdefs, 0, sizeof(XkbRF_MultiDefsRec));
    mdefs->model = defs->model;
-   mdefs->options = _XkbDupString(defs->options);
+   mdefs->options = uDupString(defs->options);
    if (mdefs->options) squeeze_spaces(mdefs->options);
 
    if (defs->layout) {
@@ -521,7 +522,7 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
        } else {
            char *p;
            int i;
-           p = _XkbDupString(defs->layout);
+           p = uDupString(defs->layout);
            if (p == NULL)
               return False;
            squeeze_spaces(p);
@@ -545,7 +546,7 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
        } else {
            char *p;
            int i;
-           p = _XkbDupString(defs->variant);
+           p = uDupString(defs->variant);
            if (p == NULL)
               return False;
            squeeze_spaces(p);
@@ -582,7 +583,7 @@ Apply(char *src, char **dst)
            *dst= _Concat(*dst, src);
         } else {
             if (*dst == NULL)
-               *dst= _XkbDupString(src);
+               *dst= uDupString(src);
         }
     }
 }
@@ -881,11 +882,11 @@ XkbcRF_AddRule(XkbRF_RulesPtr     rules)
     if (rules->sz_rules<1) {
        rules->sz_rules= 16;
        rules->num_rules= 0;
-       rules->rules= _XkbTypedCalloc(rules->sz_rules,XkbRF_RuleRec);
+       rules->rules= uTypedCalloc(rules->sz_rules,XkbRF_RuleRec);
     }
     else if (rules->num_rules>=rules->sz_rules) {
        rules->sz_rules*= 2;
-       rules->rules= _XkbTypedRealloc(rules->rules,rules->sz_rules,
+       rules->rules= uTypedRealloc(rules->rules,rules->sz_rules,
                                                        XkbRF_RuleRec);
     }
     if (!rules->rules) {
@@ -905,12 +906,12 @@ XkbcRF_AddGroup(XkbRF_RulesPtr    rules)
     if (rules->sz_groups<1) {
        rules->sz_groups= 16;
        rules->num_groups= 0;
-       rules->groups= _XkbTypedCalloc(rules->sz_groups,XkbRF_GroupRec);
+       rules->groups= uTypedCalloc(rules->sz_groups,XkbRF_GroupRec);
     }
     else if (rules->num_groups >= rules->sz_groups) {
        rules->sz_groups *= 2;
-       rules->groups= _XkbTypedRealloc(rules->groups,rules->sz_groups,
-                                                       XkbRF_GroupRec);
+       rules->groups= uTypedRealloc(rules->groups,rules->sz_groups,
+                                     XkbRF_GroupRec);
     }
     if (!rules->groups) {
        rules->sz_groups= rules->num_groups= 0;
index 2fbf87a..0b0582b 100644 (file)
 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 */
index f21627e..6b30232 100644 (file)
@@ -708,7 +708,7 @@ HandleCompatMapFile(XkbFile * file,
     if (merge == MergeDefault)
         merge = MergeAugment;
     free(info->name);
-    info->name = _XkbDupString(file->name);
+    info->name = uDupString(file->name);
     stmt = file->defs;
     while (stmt)
     {
index 55328c2..4d03bd6 100644 (file)
@@ -32,6 +32,7 @@
 #include "vmod.h"
 #include "indicators.h"
 #include "action.h"
+#include "utils.h"
 
 /***====================================================================***/
 
index a65bb1a..88dcb50 100644 (file)
@@ -92,7 +92,7 @@ ResizeKeyNameArrays(KeyNamesInfo *info, int newMax)
     void *tmp;
     int i;
 
-    tmp = _XkbTypedRealloc(info->names, newMax + 1, unsigned long);
+    tmp = uTypedRealloc(info->names, newMax + 1, unsigned long);
     if (!tmp) {
         ERROR
             ("Couldn't reallocate for larger maximum keycode (%d)\n",
@@ -104,7 +104,7 @@ ResizeKeyNameArrays(KeyNamesInfo *info, int newMax)
     for (i = info->arraySize + 1; i <= newMax; i++)
         info->names[i] = 0;
 
-    tmp = _XkbTypedRealloc(info->files, newMax + 1, unsigned);
+    tmp = uTypedRealloc(info->files, newMax + 1, unsigned);
     if (!tmp) {
         ERROR
             ("Couldn't reallocate for larger maximum keycode (%d)\n",
@@ -116,7 +116,7 @@ ResizeKeyNameArrays(KeyNamesInfo *info, int newMax)
     for (i = info->arraySize + 1; i <= newMax; i++)
         info->files[i] = 0;
 
-    tmp = _XkbTypedRealloc(info->has_alt_forms, newMax + 1, unsigned char);
+    tmp = uTypedRealloc(info->has_alt_forms, newMax + 1, unsigned char);
     if (!tmp) {
         ERROR
             ("Couldn't reallocate for larger maximum keycode (%d)\n",
@@ -805,7 +805,7 @@ HandleKeycodesFile(XkbFile * file,
     ParseCommon *stmt;
 
     free(info->name);
-    info->name = _XkbDupString(file->name);
+    info->name = uDupString(file->name);
     stmt = file->defs;
     while (stmt)
     {
index 0e00666..ab31706 100644 (file)
@@ -1012,7 +1012,7 @@ HandleKeyTypesFile(XkbFile * file,
     ParseCommon *stmt;
 
     free(info->name);
-    info->name = _XkbDupString(file->name);
+    info->name = uDupString(file->name);
     stmt = file->defs;
     while (stmt)
     {
index 107be23..32f7484 100644 (file)
@@ -473,7 +473,7 @@ IncludeCreate(char *str, unsigned merge)
     incl = first = NULL;
     file = map = NULL;
     tmp = str;
-    stmt = _XkbDupString(str);
+    stmt = uDupString(str);
     while ((tmp) && (*tmp))
     {
         if (XkbParseIncludeMap(&tmp, &file, &map, &nextop, &extra_data))
@@ -592,7 +592,7 @@ CreateXKBFile(int type, char *name, ParseCommon * defs, unsigned flags)
         XkbcEnsureSafeMapName(name);
         memset(file, 0, sizeof(XkbFile));
         file->type = type;
-        file->topName = _XkbDupString(name);
+        file->topName = uDupString(name);
         file->name = name;
         file->defs = defs;
         file->id = fileID++;
index 726e9d0..6defce2 100644 (file)
@@ -1454,7 +1454,7 @@ HandleSymbolsFile(XkbFile * file,
     ParseCommon *stmt;
 
     free(info->name);
-    info->name = _XkbDupString(file->name);
+    info->name = uDupString(file->name);
     stmt = file->defs;
     while (stmt)
     {
index b229688..991ec60 100644 (file)
@@ -77,7 +77,7 @@ XkbComponentsFromRules(const char *rules, const XkbRF_VarDefsPtr defs)
         return NULL;
     }
 
-    if (!(loaded = _XkbTypedCalloc(1, XkbRF_RulesRec))) {
+    if (!(loaded = uTypedCalloc(1, XkbRF_RulesRec))) {
         ERROR("failed to allocate XKB rules\n");
         goto unwind_file;
     }
@@ -87,7 +87,7 @@ XkbComponentsFromRules(const char *rules, const XkbRF_VarDefsPtr defs)
         goto unwind_file;
     }
 
-    if (!(names = _XkbTypedCalloc(1, struct xkb_component_names))) {
+    if (!(names = uTypedCalloc(1, struct xkb_component_names))) {
         ERROR("failed to allocate XKB components\n");
         goto unwind_file;
     }
index 505d8ba..06dd71a 100644 (file)
@@ -115,7 +115,7 @@ XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
         if (tmp != NULL)
         {
             *tmp++ = '\0';
-            *extra_data = _XkbDupString(tmp);
+            *extra_data = uDupString(tmp);
         }
         else
         {
@@ -124,7 +124,7 @@ XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
         tmp = strchr(str, '(');
         if (tmp == NULL)
         {
-            *file_rtrn = _XkbDupString(str);
+            *file_rtrn = uDupString(str);
             *map_rtrn = NULL;
         }
         else if (str[0] == '(')
@@ -135,7 +135,7 @@ XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
         else
         {
             *tmp++ = '\0';
-            *file_rtrn = _XkbDupString(str);
+            *file_rtrn = uDupString(str);
             str = tmp;
             tmp = strchr(str, ')');
             if ((tmp == NULL) || (tmp[1] != '\0'))
@@ -145,7 +145,7 @@ XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
                 return False;
             }
             *tmp++ = '\0';
-            *map_rtrn = _XkbDupString(str);
+            *map_rtrn = uDupString(str);
         }
     }
     if (*nextop_rtrn == '\0')