aboutsummaryrefslogtreecommitdiff
path: root/nx-X11
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2017-12-08 00:17:24 +0100
committerUlrich Sibiller <uli42@gmx.de>2018-01-07 01:27:07 +0100
commit9d5c83e2fd215e9e6a6345bc11ee195789e028cb (patch)
treee4fcc8cf0e23f5c0b9465d79c11789e60d7ddaf1 /nx-X11
parent2836c72f786e550252d75cf5f274245e8de5b5f9 (diff)
downloadnx-libs-9d5c83e2fd215e9e6a6345bc11ee195789e028cb.tar.gz
nx-libs-9d5c83e2fd215e9e6a6345bc11ee195789e028cb.tar.bz2
nx-libs-9d5c83e2fd215e9e6a6345bc11ee195789e028cb.zip
Font.c: shorten string handling
Diffstat (limited to 'nx-X11')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Font.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Font.c b/nx-X11/programs/Xserver/hw/nxagent/Font.c
index c7fcaf346..0a9f6e3c3 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Font.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Font.c
@@ -1452,9 +1452,11 @@ void nxagentVerifyDefaultFontPath(void)
fprintf(stderr, "nxagentVerifyDefaultFontPath: Going to search for one or more valid font paths.\n");
#endif
- fontPath = malloc(strlen(defaultFontPath) + 1);
+ /*
+ * Set the default font path as the first choice.
+ */
- if (fontPath == NULL)
+ if ((fontPath = strdup(defaultFontPath)) == NULL)
{
#ifdef WARNING
fprintf(stderr, "nxagentVerifyDefaultFontPath: WARNING! Unable to allocate memory for a new font path. "
@@ -1464,12 +1466,6 @@ void nxagentVerifyDefaultFontPath(void)
return;
}
- /*
- * Set the default font path as the first choice.
- */
-
- strcpy(fontPath, defaultFontPath);
-
if (stat(NXAGENT_DEFAULT_FONT_DIR, &dirStat) == 0 &&
S_ISDIR(dirStat.st_mode) != 0)
{
@@ -1741,9 +1737,7 @@ int nxagentSplitString(char *string, char *fields[], int nfields, char *sep)
if (i < nfields)
{
- fields[i] = (char *) malloc(fieldlen + 1);
- strncpy(fields[i], current, fieldlen);
- *(fields[i] + fieldlen) = 0;
+ fields[i] = strndup(current, fieldlen);
}
else
{
@@ -1767,14 +1761,9 @@ char *nxagentMakeScalableFontName(const char *fontName, int scalableResolution)
{
char *scalableFontName;
const char *s;
- int len;
int field;
- len = strlen(fontName) + 1;
-
- scalableFontName = malloc(len);
-
- if (scalableFontName == NULL)
+ if ((scalableFontName = malloc(strlen(fontName) + 1)) == NULL)
{
#ifdef PANIC
fprintf(stderr, "nxagentMakeScalableFontName: PANIC! malloc() failed.\n");
@@ -1783,7 +1772,7 @@ char *nxagentMakeScalableFontName(const char *fontName, int scalableResolution)
return NULL;
}
- scalableFontName[0] = 0;
+ scalableFontName[0] = '\0';
if (*fontName != '-')
{