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/fcstr.c | 65 ++++++++++++++------------------------------------ 1 file changed, 18 insertions(+), 47 deletions(-) (limited to 'fontconfig/src/fcstr.c') diff --git a/fontconfig/src/fcstr.c b/fontconfig/src/fcstr.c index cc1465cc9..cdab38397 100644 --- a/fontconfig/src/fcstr.c +++ b/fontconfig/src/fcstr.c @@ -29,24 +29,13 @@ #ifdef HAVE_REGEX_H #include #endif -#ifdef _WIN32 -#include -#endif + +/* Objects MT-safe for readonly access. */ FcChar8 * FcStrCopy (const FcChar8 *s) { - int len; - FcChar8 *r; - if (!s) - return 0; - len = strlen ((char *) s) + 1; - r = (FcChar8 *) malloc (len); - if (!r) - return 0; - FcMemAlloc (FC_MEM_STRING, len); - memcpy (r, s, len); - return r; + return FcStrdup (s); } FcChar8 * @@ -59,7 +48,6 @@ FcStrPlus (const FcChar8 *s1, const FcChar8 *s2) if (!s) return 0; - FcMemAlloc (FC_MEM_STRING, l); memcpy (s, s1, s1l); memcpy (s + s1l, s2, s2l + 1); return s; @@ -68,7 +56,6 @@ FcStrPlus (const FcChar8 *s1, const FcChar8 *s2) void FcStrFree (FcChar8 *s) { - FcMemFree (FC_MEM_STRING, strlen ((char *) s) + 1); free (s); } @@ -78,8 +65,6 @@ FcStrFree (FcChar8 *s) #define FcCaseFoldUpperCount(cf) \ ((cf)->method == FC_CASE_FOLD_FULL ? 1 : (cf)->count) -#define FC_STR_CANON_BUF_LEN 1024 - typedef struct _FcCaseWalker { const FcChar8 *read; const FcChar8 *src; @@ -206,7 +191,6 @@ FcStrDowncase (const FcChar8 *s) d = dst = malloc (len + 1); if (!d) return 0; - FcMemAlloc (FC_MEM_STRING, len + 1); FcStrCaseWalkerInit (s, &w); while ((*d++ = FcStrCaseWalkerNext (&w))); return dst; @@ -782,7 +766,6 @@ FcStrBufDestroy (FcStrBuf *buf) { if (buf->allocated) { - FcMemFree (FC_MEM_STRBUF, buf->size); free (buf->buf); FcStrBufInit (buf, 0, 0); } @@ -799,7 +782,6 @@ FcStrBufDone (FcStrBuf *buf) ret = malloc (buf->len + 1); if (ret) { - FcMemAlloc (FC_MEM_STRING, buf->len + 1); memcpy (ret, buf->buf, buf->len); ret[buf->len] = '\0'; } @@ -832,7 +814,6 @@ FcStrBufChar (FcStrBuf *buf, FcChar8 c) if (buf->allocated) { size = buf->size * 2; - FcMemFree (FC_MEM_STRBUF, buf->size); new = realloc (buf->buf, size); } else @@ -850,7 +831,6 @@ FcStrBufChar (FcStrBuf *buf, FcChar8 c) buf->failed = FcTrue; return FcFalse; } - FcMemAlloc (FC_MEM_STRBUF, size); buf->size = size; buf->buf = new; } @@ -941,7 +921,6 @@ FcStrDirname (const FcChar8 *file) dir = malloc ((slash - file) + 1); if (!dir) return 0; - FcMemAlloc (FC_MEM_STRING, (slash - file) + 1); strncpy ((char *) dir, (const char *) file, slash - file); dir[slash - file] = '\0'; return dir; @@ -970,7 +949,6 @@ FcStrCanonAbsoluteFilename (const FcChar8 *s) file = malloc (size); if (!file) return NULL; - FcMemAlloc (FC_MEM_STRING, size); slash = NULL; f = file; #ifdef _WIN32 @@ -1090,8 +1068,7 @@ FcStrSetCreate (void) FcStrSet *set = malloc (sizeof (FcStrSet)); if (!set) return 0; - FcMemAlloc (FC_MEM_STRSET, sizeof (FcStrSet)); - set->ref = 1; + FcRefInit (&set->ref, 1); set->num = 0; set->size = 0; set->strs = 0; @@ -1112,14 +1089,10 @@ _FcStrSetAppend (FcStrSet *set, FcChar8 *s) if (!strs) return FcFalse; - FcMemAlloc (FC_MEM_STRSET, (set->size + 2) * sizeof (FcChar8 *)); if (set->num) memcpy (strs, set->strs, set->num * sizeof (FcChar8 *)); if (set->strs) - { - FcMemFree (FC_MEM_STRSET, (set->size + 1) * sizeof (FcChar8 *)); free (set->strs); - } set->size = set->size + 1; set->strs = strs; } @@ -1247,20 +1220,20 @@ 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) - { - FcMemFree (FC_MEM_STRSET, (set->size + 1) * sizeof (FcChar8 *)); - free (set->strs); - } - FcMemFree (FC_MEM_STRSET, sizeof (FcStrSet)); - free (set); - } + /* We rely on this in FcGetDefaultLangs for caching. */ + if (FcRefIsConst (&set->ref)) + return; + + 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 * @@ -1271,9 +1244,8 @@ FcStrListCreate (FcStrSet *set) list = malloc (sizeof (FcStrList)); if (!list) return 0; - FcMemAlloc (FC_MEM_STRLIST, sizeof (FcStrList)); list->set = set; - set->ref++; + FcRefInc (&set->ref); list->n = 0; return list; } @@ -1290,7 +1262,6 @@ void FcStrListDone (FcStrList *list) { FcStrSetDestroy (list->set); - FcMemFree (FC_MEM_STRLIST, sizeof (FcStrList)); free (list); } -- cgit v1.2.3