#define PATH_MAX 1024
#endif
-#define PATH_CHUNK 8 /* initial szPath */
+/* initial szPath */
+#define PATH_CHUNK 8
static Bool noDefaultPath = False;
-static int szPath; /* number of entries allocated for includePath */
-static int nPathEntries; /* number of actual entries in includePath */
-static char **includePath; /* Holds all directories we might be including data from */
+/* number of entries allocated for includePath */
+static int szPath;
+/* number of actual entries in includePath */
+static int nPathEntries;
+/* Holds all directories we might be including data from */
+static char **includePath = NULL;
/**
* Extract the first token from an include statement.
Bool
XkbInitIncludePath(void)
{
+ if (includePath)
+ return True;
+
szPath = PATH_CHUNK;
includePath = (char **) calloc(szPath, sizeof(char *));
- if (includePath == NULL)
+ if (!includePath)
return False;
+
+ XkbAddDefaultDirectoriesToPath();
return True;
}
void
XkbAddDefaultDirectoriesToPath(void)
{
+ if (!XkbInitIncludePath())
+ return;
if (noDefaultPath)
return;
XkbAddDirectoryToPath(DFLT_XKB_CONFIG_ROOT);
XkbAddDirectoryToPath(const char *dir)
{
int len;
+
+ if (!XkbInitIncludePath())
+ return False;
+
if ((dir == NULL) || (dir[0] == '\0'))
{
XkbClearIncludePath();
int nameLen, typeLen, pathLen;
char buf[PATH_MAX], *typeDir;
+ if (!XkbInitIncludePath())
+ return NULL;
+
typeDir = XkbDirectoryForInclude(type);
nameLen = strlen(name);
typeLen = strlen(typeDir);