Commit a4700c9d authored by Ulrich Sibiller's avatar Ulrich Sibiller

Font.c: use SAFE_XFree and SAFE_free

parent d8012d2a
...@@ -188,11 +188,11 @@ void nxagentFreeFontCache(void) ...@@ -188,11 +188,11 @@ void nxagentFreeFontCache(void)
nxagentFreeFont(CACHE_FSTRUCT(i)); nxagentFreeFont(CACHE_FSTRUCT(i));
} }
free(CACHE_NAME(i)); SAFE_free(CACHE_NAME(i));
free(CACHE_ENTRY(i)); SAFE_free(CACHE_ENTRY(i));
} }
free(CACHE_ENTRY_PTR); SAFE_free(CACHE_ENTRY_PTR);
CACHE_ENTRY_PTR = NULL; CACHE_ENTRY_PTR = NULL;
CACHE_INDEX = 0; CACHE_INDEX = 0;
CACHE_SIZE = 0; CACHE_SIZE = 0;
...@@ -324,8 +324,7 @@ void nxagentListRemoteAddName(const char *name, int status) ...@@ -324,8 +324,7 @@ void nxagentListRemoteAddName(const char *name, int status)
if (nxagentRemoteFontList.list[pos]->name == NULL) if (nxagentRemoteFontList.list[pos]->name == NULL)
{ {
fprintf(stderr, "Font: remote list name memory allocation failed!.\n"); fprintf(stderr, "Font: remote list name memory allocation failed!.\n");
free(nxagentRemoteFontList.list[pos]); SAFE_free(nxagentRemoteFontList.list[pos]);
nxagentRemoteFontList.list[pos] = NULL;
return; return;
} }
} }
...@@ -351,18 +350,14 @@ static void nxagentFreeRemoteFontList(nxagentFontList *listRec) ...@@ -351,18 +350,14 @@ static void nxagentFreeRemoteFontList(nxagentFontList *listRec)
{ {
if (listRec -> list[l]) if (listRec -> list[l])
{ {
free(listRec -> list[l] -> name); SAFE_free(listRec -> list[l] -> name);
listRec -> list[l] -> name = NULL; SAFE_free(listRec -> list[l]);
free(listRec -> list[l]);
listRec -> list[l] = NULL;
} }
} }
listRec -> length = listRec -> listSize = 0; listRec -> length = listRec -> listSize = 0;
free(listRec -> list); SAFE_free(listRec -> list);
listRec -> list = NULL;
return; return;
} }
...@@ -434,7 +429,7 @@ Bool nxagentFontLookUp(const char *name) ...@@ -434,7 +429,7 @@ Bool nxagentFontLookUp(const char *name)
{ {
result = nxagentFontFind(scalable, &i); result = nxagentFontFind(scalable, &i);
free(scalable); SAFE_free(scalable);
} }
} }
...@@ -448,7 +443,7 @@ Bool nxagentFontLookUp(const char *name) ...@@ -448,7 +443,7 @@ Bool nxagentFontLookUp(const char *name)
{ {
result = nxagentFontFind(scalable, &i); result = nxagentFontFind(scalable, &i);
free(scalable); SAFE_free(scalable);
} }
} }
...@@ -813,7 +808,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP ...@@ -813,7 +808,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
for (j = 0; j < numSearchFields; j++) for (j = 0; j < numSearchFields; j++)
{ {
free(searchFields[j]); SAFE_free(searchFields[j]);
} }
} }
} }
...@@ -830,7 +825,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP ...@@ -830,7 +825,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
for (j = 0; j < numFontFields; j++) for (j = 0; j < numFontFields; j++)
{ {
free(fontNameFields[j]); SAFE_free(fontNameFields[j]);
} }
return fontStruct; return fontStruct;
...@@ -890,10 +885,8 @@ static void nxagentCollectFailedFont(FontPtr fpt, XID id) ...@@ -890,10 +885,8 @@ static void nxagentCollectFailedFont(FontPtr fpt, XID id)
if (nxagentFailedToReconnectFonts.font == NULL || nxagentFailedToReconnectFonts.id == NULL) if (nxagentFailedToReconnectFonts.font == NULL || nxagentFailedToReconnectFonts.id == NULL)
{ {
free(nxagentFailedToReconnectFonts.font); SAFE_free(nxagentFailedToReconnectFonts.font);
nxagentFailedToReconnectFonts.font = NULL; SAFE_free(nxagentFailedToReconnectFonts.id);
free(nxagentFailedToReconnectFonts.id);
nxagentFailedToReconnectFonts.id = NULL;
FatalError("Font: font not reconnected memory allocation failed!.\n"); FatalError("Font: font not reconnected memory allocation failed!.\n");
} }
...@@ -1050,7 +1043,7 @@ static void nxagentCleanCacheAfterReconnect(void) ...@@ -1050,7 +1043,7 @@ static void nxagentCleanCacheAfterReconnect(void)
{ {
if(CACHE_FSTRUCT(i) == NULL) if(CACHE_FSTRUCT(i) == NULL)
{ {
XFree(CACHE_NAME(i)); SAFE_XFree(CACHE_NAME(i));
real_size--; real_size--;
} }
} }
...@@ -1223,11 +1216,8 @@ static void nxagentFailedFontReconnect(FontPtr pFont, XID param1, void * param2) ...@@ -1223,11 +1216,8 @@ static void nxagentFailedFontReconnect(FontPtr pFont, XID param1, void * param2)
static void nxagentFreeFailedToReconnectFonts(void) static void nxagentFreeFailedToReconnectFonts(void)
{ {
free(nxagentFailedToReconnectFonts.font); SAFE_free(nxagentFailedToReconnectFonts.font);
nxagentFailedToReconnectFonts.font = NULL; SAFE_free(nxagentFailedToReconnectFonts.id);
free(nxagentFailedToReconnectFonts.id);
nxagentFailedToReconnectFonts.id = NULL;
nxagentFailedToReconnectFonts.size = 0; nxagentFailedToReconnectFonts.size = 0;
nxagentFailedToReconnectFonts.index = 0; nxagentFailedToReconnectFonts.index = 0;
...@@ -1321,7 +1311,7 @@ Bool nxagentReconnectFailedFonts(void *p0) ...@@ -1321,7 +1311,7 @@ Bool nxagentReconnectFailedFonts(void *p0)
nxagentListRemoteFonts("*", nxagentMaxFontNames); nxagentListRemoteFonts("*", nxagentMaxFontNames);
XFreeFontPath(fontPaths); XFreeFontPath(fontPaths);
free(newFontPaths); SAFE_free(newFontPaths);
return False; return False;
} }
...@@ -1332,7 +1322,7 @@ Bool nxagentReconnectFailedFonts(void *p0) ...@@ -1332,7 +1322,7 @@ Bool nxagentReconnectFailedFonts(void *p0)
XSetFontPath(nxagentDisplay, fontPaths, nPaths); XSetFontPath(nxagentDisplay, fontPaths, nPaths);
XFreeFontPath(fontPaths); XFreeFontPath(fontPaths);
free(newFontPaths); SAFE_free(newFontPaths);
nxagentCleanCacheAfterReconnect(); nxagentCleanCacheAfterReconnect();
...@@ -1442,7 +1432,7 @@ void nxagentVerifySingleFontPath(char **dest, const char *fontDir) ...@@ -1442,7 +1432,7 @@ void nxagentVerifySingleFontPath(char **dest, const char *fontDir)
if (rc == -1) if (rc == -1)
return; return;
free(*dest); SAFE_free(*dest);
*dest = tmppath; *dest = tmppath;
tmppath = NULL; tmppath = NULL;
} }
...@@ -1554,7 +1544,7 @@ XFontStruct* nxagentLoadQueryFont(register Display *dpy, char *name, FontPtr pFo ...@@ -1554,7 +1544,7 @@ XFontStruct* nxagentLoadQueryFont(register Display *dpy, char *name, FontPtr pFo
fprintf(stderr, "nxagentLoadQueryFont: WARNING! Font not found '%s'.\n", name); fprintf(stderr, "nxagentLoadQueryFont: WARNING! Font not found '%s'.\n", name);
#endif #endif
free(fs); SAFE_free(fs);
return (XFontStruct *) NULL; return (XFontStruct *) NULL;
} }
...@@ -1588,7 +1578,7 @@ XFontStruct* nxagentLoadQueryFont(register Display *dpy, char *name, FontPtr pFo ...@@ -1588,7 +1578,7 @@ XFontStruct* nxagentLoadQueryFont(register Display *dpy, char *name, FontPtr pFo
fprintf(stderr, "nxagentLoadQueryFont: WARNING! Failed allocation of XFontProp."); fprintf(stderr, "nxagentLoadQueryFont: WARNING! Failed allocation of XFontProp.");
#endif #endif
free((char *) fs); SAFE_free(fs);
return (XFontStruct *) NULL; return (XFontStruct *) NULL;
} }
...@@ -1622,18 +1612,17 @@ XFontStruct* nxagentLoadQueryFont(register Display *dpy, char *name, FontPtr pFo ...@@ -1622,18 +1612,17 @@ XFontStruct* nxagentLoadQueryFont(register Display *dpy, char *name, FontPtr pFo
int nxagentFreeFont(XFontStruct *fs) int nxagentFreeFont(XFontStruct *fs)
{ {
if (fs -> per_char) if (fs->per_char)
{ {
#ifdef USE_XF86BIGFONT #ifdef USE_XF86BIGFONT
_XF86BigfontFreeFontMetrics(fs); _XF86BigfontFreeFontMetrics(fs);
#else #else
free ((char *) fs->per_char); SAFE_free(fs->per_char);
#endif #endif
} }
free (fs->properties); SAFE_free(fs->properties);
SAFE_XFree(fs);
XFree(fs);
return 1; return 1;
} }
...@@ -1769,7 +1758,7 @@ char *nxagentMakeScalableFontName(const char *fontName, int scalableResolution) ...@@ -1769,7 +1758,7 @@ char *nxagentMakeScalableFontName(const char *fontName, int scalableResolution)
MakeScalableFontNameError: MakeScalableFontNameError:
free(scalableFontName); SAFE_free(scalableFontName);
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "nxagentMakeScalableFontName: Invalid font name.\n"); fprintf(stderr, "nxagentMakeScalableFontName: Invalid font name.\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment