From 3f553aaceddc9b09363c73d9bea40eaea8164fc4 Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 7 Jan 2013 11:56:06 +0100 Subject: pixman xkbcomp libX11 libXau mesa fontconfig xserver xkeyboard-config git update 7 jan 2013 fontconfig: 17eda89ed2e24a3fc5f68538dd7fd9ada8efb087 xserver: bd91b05b631f13afd1f7a9d6cbc4f0c5408b523a xkeyboard-config: 4779e2745094ebe0c06364b4099d7067ae750d07 libX11: cd25cab4b5b957641183ce72dd1ae0424aff1663 libXau: e04364efccbb3bb4cfc5f4cb491ffa1faaaacbdb mesa: afec10df373f342f058aab66c622237964a4a147 pixman: 35cc965514ca6e665c18411fcf66db826d559c2a xkbcomp: e4f767913338052527538d429931e8abd8c3fb88 --- fontconfig/src/fclang.c | 66 +++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 38 deletions(-) (limited to 'fontconfig/src/fclang.c') 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 #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 -- cgit v1.2.3