diff options
author | Peng Wu <pwu@redhat.com> | 2021-07-15 11:03:15 +0800 |
---|---|---|
committer | Peng Wu <pwu@redhat.com> | 2021-07-21 14:20:29 +0800 |
commit | 2743d99312fcf5831e924e1a7089712aeab54f38 (patch) | |
tree | 9a669ae147a3f7b101fe1a9a403427ec07a79834 /pango/break-thai.c | |
parent | a4ad59a23a5ab169644bad157a0890c415c5da6c (diff) | |
download | pango-2743d99312fcf5831e924e1a7089712aeab54f38.tar.gz |
Use GMutex for the thai_brk
Use GMutex to protect the thai_brk in multithreading.
Diffstat (limited to 'pango/break-thai.c')
-rw-r--r-- | pango/break-thai.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/pango/break-thai.c b/pango/break-thai.c index 85b9e54a..871c0869 100644 --- a/pango/break-thai.c +++ b/pango/break-thai.c @@ -27,8 +27,10 @@ #include <thai/thwchar.h> #include <thai/thbrk.h> -#ifndef HAVE_TH_BRK_FIND_BREAKS -G_LOCK_DEFINE_STATIC (th_brk); +G_LOCK_DEFINE_STATIC (thai_brk); + +#ifdef HAVE_TH_BRK_FIND_BREAKS +static ThBrk *thai_brk = NULL; #endif /* @@ -79,13 +81,15 @@ break_thai (const char *text, /* find line break positions */ + G_LOCK (thai_brk); #ifdef HAVE_TH_BRK_FIND_BREAKS - len = th_brk_find_breaks(NULL, tis_text, brk_pnts, cnt); + if (thai_brk == NULL) + thai_brk = th_brk_new(NULL); + len = th_brk_find_breaks(thai_brk, tis_text, brk_pnts, cnt); #else - G_LOCK (th_brk); len = th_brk (tis_text, brk_pnts, cnt); - G_UNLOCK (th_brk); #endif + G_UNLOCK (thai_brk); for (cnt = 0; cnt < len; cnt++) if (attrs[brk_pnts[cnt]].is_char_break) |