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 | |
parent | 8b2a314c267071656ca4d86bae56c6d82bb8127a (diff) |
Replace malloc(strlen()+1); strcpy(); pairs with strdup()
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | src/gram.y | 3 | ||||
-rw-r--r-- | src/session.c | 13 |
2 files changed, 4 insertions, 12 deletions
@@ -652,8 +652,7 @@ button : BUTTON number { $$ = $2; } ; -string : STRING { ptr = malloc(strlen($1)+1); - strcpy(ptr, $1); +string : STRING { ptr = strdup($1); RemoveDQuote(ptr); $$ = ptr; } 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 } |