summaryrefslogtreecommitdiff
path: root/src/fcstr.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2012-10-07 14:41:38 -0400
committerBehdad Esfahbod <behdad@behdad.org>2013-01-02 00:51:00 -0600
commit64af9e1917114c789ad74dd28b3248f8c0525f45 (patch)
tree31023c299c7cdd6bfc9632e1ae103c8fbf839499 /src/fcstr.c
parent814871b2aaa3a22ef711ca4656507fb69c952156 (diff)
Make refcounts, patterns, charsets, strings, and FcLang thread-safe
Diffstat (limited to 'src/fcstr.c')
-rw-r--r--src/fcstr.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/fcstr.c b/src/fcstr.c
index 553588fa..e72be5e2 100644
--- a/src/fcstr.c
+++ b/src/fcstr.c
@@ -33,6 +33,8 @@
#include <windows.h>
#endif
+/* Objects MT-safe for readonly access. */
+
FcChar8 *
FcStrCopy (const FcChar8 *s)
{
@@ -1078,7 +1080,7 @@ FcStrSetCreate (void)
FcStrSet *set = malloc (sizeof (FcStrSet));
if (!set)
return 0;
- set->ref = 1;
+ FcRefInit (&set->ref, 1);
set->num = 0;
set->size = 0;
set->strs = 0;
@@ -1230,16 +1232,16 @@ FcStrSetDel (FcStrSet *set, const FcChar8 *s)
void
FcStrSetDestroy (FcStrSet *set)
{
- if (--set->ref == 0)
- {
- int i;
+ int i;
- for (i = 0; i < set->num; i++)
- FcStrFree (set->strs[i]);
- if (set->strs)
- free (set->strs);
- free (set);
- }
+ if (FcRefDec (&set->ref) != 1)
+ return;
+
+ for (i = 0; i < set->num; i++)
+ FcStrFree (set->strs[i]);
+ if (set->strs)
+ free (set->strs);
+ free (set);
}
FcStrList *
@@ -1251,7 +1253,7 @@ FcStrListCreate (FcStrSet *set)
if (!list)
return 0;
list->set = set;
- set->ref++;
+ FcRefInc (&set->ref);
list->n = 0;
return list;
}