FcConfigFileExists (const FcChar8 *dir, const FcChar8 *file)
{
FcChar8 *path;
- int size;
if (!dir)
- dir = (FcChar8 *) "";
+ dir = (const FcChar8 *) "";
- size = strlen ((char *) dir) + 1 + strlen ((char *) file) + 1;
- /*
- * workaround valgrind warning because glibc takes advantage of how it knows memory is
- * allocated to implement strlen by reading in groups of 4
- */
- size = (size + 3) & ~3;
-
- path = malloc (size);
- if (!path)
- return 0;
-
- strcpy ((char *) path, (const char *) dir);
- /* make sure there's a single separator */
-#ifdef _WIN32
- if ((!path[0] || (path[strlen((char *) path)-1] != '/' &&
- path[strlen((char *) path)-1] != '\\')) &&
- !(file[0] == '/' ||
- file[0] == '\\' ||
- (isalpha (file[0]) && file[1] == ':' && (file[2] == '/' || file[2] == '\\'))))
- strcat ((char *) path, "\\");
-#else
- if ((!path[0] || path[strlen((char *) path)-1] != '/') && file[0] != '/')
- strcat ((char *) path, "/");
-#endif
- strcat ((char *) path, (char *) file);
-
- FcMemAlloc (FC_MEM_STRING, size);
+ path = FcStrPathPlus (dir, file, NULL);
if (access ((char *) path, R_OK) == 0)
return path;