+/* we don't store these in the FcPattern itself because
+ * we don't want to serialize the directory names */
+
+/* I suppose this should be cleaned, too... */
+typedef struct _FcPatternDirMapping {
+ const FcPattern *p;
+ const char *fname;
+} FcPatternDirMapping;
+
+#define PATTERNDIR_HASH_SIZE 31
+static struct patternDirBucket {
+ struct patternDirBucket *next;
+ FcPatternDirMapping m;
+} FcPatternDirBuckets[PATTERNDIR_HASH_SIZE];
+
+void
+FcPatternAddFullFname (const FcPattern *p, const char *fname)
+{
+ struct patternDirBucket *pb;
+
+ /* N.B. FcPatternHash fails, since it's contents-based, not
+ * address-based, and we're in the process of mutating the FcPattern. */
+ for (pb = &FcPatternDirBuckets
+ [((int)p / sizeof (FcPattern *)) % PATTERNDIR_HASH_SIZE];
+ pb->m.p != p && pb->next;
+ pb = pb->next)
+ ;
+
+ if (pb->m.p == p)
+ {
+ pb->m.fname = fname;
+ return;
+ }
+
+ pb->next = malloc (sizeof (struct patternDirBucket));
+ if (!pb->next)
+ return;
+ FcMemAlloc (FC_MEM_CACHE, sizeof (struct patternDirBucket));
+
+ pb->next->next = 0;
+ pb->next->m.p = p;
+ pb->next->m.fname = fname;
+}
+
+const char *
+FcPatternFindFullFname (const FcPattern *p)
+{
+ struct patternDirBucket *pb;
+
+ for (pb = &FcPatternDirBuckets
+ [((int)p / sizeof (FcPattern *)) % PATTERNDIR_HASH_SIZE];
+ pb; pb = pb->next)
+ if (pb->m.p == p)
+ return pb->m.fname;
+
+ return 0;
+}
+