diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-08-18 10:50:01 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-08-18 10:50:01 -0700 |
commit | 97b55a970dc5281c2d41500990d99fcd24d2dd5f (patch) | |
tree | 8fe27f9eb52684eefd17d819ccc82ab5500abce2 /src/session.c | |
parent | 8b2a314c267071656ca4d86bae56c6d82bb8127a (diff) |
Replace malloc(strlen()+1); strcpy(); pairs with strdup()
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'src/session.c')
-rw-r--r-- | src/session.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/session.c b/src/session.c index e5ffb61..e12a6c0 100644 --- a/src/session.c +++ b/src/session.c @@ -701,11 +701,7 @@ unique_filename ( snprintf (tempFile, sizeof(tempFile), "%s/%sXXXXXX", path, prefix); tmp = (char *) mktemp (tempFile); if (tmp) - { - char *ptr = malloc (strlen (tmp) + 1); - strcpy (ptr, tmp); - return (ptr); - } + return strdup (tmp); else return (NULL); #endif @@ -714,12 +710,9 @@ unique_filename ( char *ptr; snprintf (tempFile, sizeof(tempFile), "%s/%sXXXXXX", path, prefix); - ptr = malloc(strlen(tempFile) + 1); + ptr = strdup (tempFile); if (ptr != NULL) - { - strcpy(ptr, tempFile); - *pFd = mkstemp(ptr); - } + *pFd = mkstemp (ptr); return ptr; #endif } |