From 772470d0e4fef8e0a3d6eaf4c563fa7b1f6d6d19 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 11 Dec 2022 15:32:03 -0800 Subject: Replace calloc(strlen())+strcpy() pairs with strdup() calls Signed-off-by: Alan Coopersmith --- xkbpath.c | 9 +++------ 1 file 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; } -- cgit v1.2.3