summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-12-11 15:32:03 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-01-03 11:02:11 -0800
commit772470d0e4fef8e0a3d6eaf4c563fa7b1f6d6d19 (patch)
tree301beb87e195054ef73a1caf187eaa0b9a376aae
parent6db8fd556e2562e9a0a821c0d6fd4f7cdcf6266c (diff)
downloadxorg-app-xkbcomp-772470d0e4fef8e0a3d6eaf4c563fa7b1f6d6d19.tar.gz
Replace calloc(strlen())+strcpy() pairs with strdup() calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--xkbpath.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/xkbpath.c b/xkbpath.c
index ef8d68c..6d9d13a 100644
--- a/xkbpath.c
+++ b/xkbpath.c
@@ -224,14 +224,13 @@ XkbAddDirectoryToPath(const char *dir)
else
includePath = new;
}
- includePath[nPathEntries] =
- (char *) calloc(strlen(dir) + 1, sizeof(char));
+ includePath[nPathEntries] = strdup(dir);
if (includePath[nPathEntries] == NULL)
{
WSGO("Allocation failed (includePath[%d])\n", nPathEntries);
return False;
}
- strcpy(includePath[nPathEntries++], dir);
+ nPathEntries++;
return True;
}
@@ -405,9 +404,7 @@ XkbFindFileInPath(const char *name, unsigned type, char **pathRtrn)
if ((file != NULL) && (pathRtrn != NULL))
{
- *pathRtrn = (char *) calloc(strlen(buf) + 1, sizeof(char));
- if (*pathRtrn != NULL)
- strcpy(*pathRtrn, buf);
+ *pathRtrn = strdup(buf);
}
return file;
}