summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-08-18 10:50:01 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2013-08-18 10:50:01 -0700
commit97b55a970dc5281c2d41500990d99fcd24d2dd5f (patch)
tree8fe27f9eb52684eefd17d819ccc82ab5500abce2 /src
parent8b2a314c267071656ca4d86bae56c6d82bb8127a (diff)
Replace malloc(strlen()+1); strcpy(); pairs with strdup()
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'src')
-rw-r--r--src/gram.y3
-rw-r--r--src/session.c13
2 files changed, 4 insertions, 12 deletions
diff --git a/src/gram.y b/src/gram.y
index 5f85327..ca40d1c 100644
--- a/src/gram.y
+++ b/src/gram.y
@@ -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
}