diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2022-12-11 15:32:03 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2023-01-03 11:02:11 -0800 |
commit | 772470d0e4fef8e0a3d6eaf4c563fa7b1f6d6d19 (patch) | |
tree | 301beb87e195054ef73a1caf187eaa0b9a376aae | |
parent | 6db8fd556e2562e9a0a821c0d6fd4f7cdcf6266c (diff) |
Replace calloc(strlen())+strcpy() pairs with strdup() calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | xkbpath.c | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -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; } |