diff options
author | marha <marha@users.sourceforge.net> | 2013-01-07 12:17:07 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2013-01-07 12:17:07 +0100 |
commit | 0e950715b62dcf30ffbf69831bf932fd348537e5 (patch) | |
tree | 83fdafc455e9906f029e2e1ad926fb35c98e7be9 /fontconfig/src/fclang.c | |
parent | 506537495e6d808f219361a5b270510c752e7a2e (diff) | |
parent | 3f553aaceddc9b09363c73d9bea40eaea8164fc4 (diff) | |
download | vcxsrv-0e950715b62dcf30ffbf69831bf932fd348537e5.tar.gz vcxsrv-0e950715b62dcf30ffbf69831bf932fd348537e5.tar.bz2 vcxsrv-0e950715b62dcf30ffbf69831bf932fd348537e5.zip |
Merge remote-tracking branch 'origin/released'
* origin/released:
pixman xkbcomp libX11 libXau mesa fontconfig xserver xkeyboard-config git update 7 jan 2013
Conflicts:
fontconfig/src/fcatomic.c
pixman/pixman/pixman-mmx.c
pixman/pixman/pixman-sse2.c
xorg-server/dix/dispatch.c
xorg-server/hw/xwin/wincursor.c
xorg-server/hw/xwin/winmsg.c
xorg-server/hw/xwin/winscrinit.c
xorg-server/hw/xwin/winsetsp.c
xorg-server/hw/xwin/winwin32rootless.c
xorg-server/xfixes/cursor.c
Diffstat (limited to 'fontconfig/src/fclang.c')
-rw-r--r-- | fontconfig/src/fclang.c | 66 |
1 files changed, 28 insertions, 38 deletions
diff --git a/fontconfig/src/fclang.c b/fontconfig/src/fclang.c index 65d22a932..8e9b094b2 100644 --- a/fontconfig/src/fclang.c +++ b/fontconfig/src/fclang.c @@ -22,10 +22,11 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#include <string.h> #include "fcint.h" #include "fcftint.h" +/* Objects MT-safe for readonly access. */ + typedef struct { const FcChar8 lang[8]; const FcCharSet charset; @@ -51,7 +52,7 @@ static void FcLangSetBitSet (FcLangSet *ls, unsigned int id) { - int bucket; + unsigned int bucket; id = fcLangCharSetIndices[id]; bucket = id >> 5; @@ -65,7 +66,7 @@ static FcBool FcLangSetBitGet (const FcLangSet *ls, unsigned int id) { - int bucket; + unsigned int bucket; id = fcLangCharSetIndices[id]; bucket = id >> 5; @@ -79,7 +80,7 @@ static void FcLangSetBitReset (FcLangSet *ls, unsigned int id) { - int bucket; + unsigned int bucket; id = fcLangCharSetIndices[id]; bucket = id >> 5; @@ -182,7 +183,7 @@ FcLangNormalize (const FcChar8 *lang) { FcChar8 *result = NULL, *s, *orig; char *territory, *encoding, *modifier; - size_t llen, tlen = 0, mlen = 0, ssize; + size_t llen, tlen = 0, mlen = 0; if (!lang || !*lang) return NULL; @@ -197,10 +198,6 @@ FcLangNormalize (const FcChar8 *lang) s = FcStrCopy (lang); if (!s) goto bail; - /* store the original length of 's' here to let FcMemFree know - * the correct size since we breaks 's' from now on. - */ - ssize = strlen ((const char *)s) + 1; /* from the comments in glibc: * @@ -289,8 +286,6 @@ FcLangNormalize (const FcChar8 *lang) /* we'll miss the opportunity to reduce the correct size * of the allocated memory for the string after that. */ - FcMemFree (FC_MEM_STRING, ssize); - FcMemAlloc (FC_MEM_STRING, strlen((const char *)s) + 1); s = NULL; goto bail1; } @@ -307,8 +302,6 @@ FcLangNormalize (const FcChar8 *lang) /* we'll miss the opportunity to reduce the correct size * of the allocated memory for the string after that. */ - FcMemFree (FC_MEM_STRING, ssize); - FcMemAlloc (FC_MEM_STRING, strlen((const char *)s) + 1); s = NULL; goto bail1; } @@ -329,8 +322,6 @@ FcLangNormalize (const FcChar8 *lang) /* we'll miss the opportunity to reduce the correct size * of the allocated memory for the string after that. */ - FcMemFree (FC_MEM_STRING, ssize); - FcMemAlloc (FC_MEM_STRING, strlen((const char *)s) + 1); s = NULL; } bail1: @@ -338,10 +329,7 @@ FcLangNormalize (const FcChar8 *lang) FcStrFree (orig); bail0: if (s) - { free (s); - FcMemFree (FC_MEM_STRING, ssize); - } bail: if (FcDebug () & FC_DBG_LANGSET) { @@ -465,7 +453,6 @@ FcLangSetCreate (void) ls = malloc (sizeof (FcLangSet)); if (!ls) return 0; - FcMemAlloc (FC_MEM_LANGSET, sizeof (FcLangSet)); memset (ls->map, '\0', sizeof (ls->map)); ls->map_size = NUM_LANG_SET_MAP; ls->extra = 0; @@ -477,7 +464,6 @@ FcLangSetDestroy (FcLangSet *ls) { if (ls->extra) FcStrSetDestroy (ls->extra); - FcMemFree (FC_MEM_LANGSET, sizeof (FcLangSet)); free (ls); } @@ -717,34 +703,38 @@ FcLangSetCompare (const FcLangSet *lsa, const FcLangSet *lsb) /* * Used in computing values -- mustn't allocate any storage - * XXX Not thread-safe */ FcLangSet * -FcLangSetPromote (const FcChar8 *lang) +FcLangSetPromote (const FcChar8 *lang, FcValuePromotionBuffer *vbuf) { - static FcLangSet ls; - static FcStrSet strs; - static FcChar8 *str; - int id; - - memset (ls.map, '\0', sizeof (ls.map)); - ls.map_size = NUM_LANG_SET_MAP; - ls.extra = 0; + int id; + typedef struct { + FcLangSet ls; + FcStrSet strs; + FcChar8 *str; + } FcLangSetPromotionBuffer; + FcLangSetPromotionBuffer *buf = (FcLangSetPromotionBuffer *) vbuf; + + FC_ASSERT_STATIC (sizeof (FcLangSetPromotionBuffer) <= sizeof (FcValuePromotionBuffer)); + + memset (buf->ls.map, '\0', sizeof (buf->ls.map)); + buf->ls.map_size = NUM_LANG_SET_MAP; + buf->ls.extra = 0; id = FcLangSetIndex (lang); if (id > 0) { - FcLangSetBitSet (&ls, id); + FcLangSetBitSet (&buf->ls, id); } else { - ls.extra = &strs; - strs.num = 1; - strs.size = 1; - strs.strs = &str; - strs.ref = 1; - str = (FcChar8 *) lang; + buf->ls.extra = &buf->strs; + buf->strs.num = 1; + buf->strs.size = 1; + buf->strs.strs = &buf->str; + FcRefInit (&buf->strs.ref, 1); + buf->str = (FcChar8 *) lang; } - return &ls; + return &buf->ls; } FcChar32 |