summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2014-11-08 15:42:03 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2014-11-08 15:59:28 -0800
commit9a17f21de44bcfe1493e9d10ae2354c2a3b496b1 (patch)
treebdb44c96824cf1652321b79d5b50ceb6a30ef9f7
parent333085a276a2bb2b156339cd9f8caa658ef4d1b6 (diff)
Replace malloc(strlen)+strcpy sets with strdup calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--config.c3
-rw-r--r--pmdb.c18
2 files changed, 7 insertions, 14 deletions
diff --git a/config.c b/config.c
index 8315f17..e11b855 100644
--- a/config.c
+++ b/config.c
@@ -172,14 +172,13 @@ GetConfig (
}
else
{
- *proxyAddress = (char *) malloc (strlen (p) + 1);
+ *proxyAddress = strdup (p);
if (! *proxyAddress) {
fprintf (stderr,
"Memory allocation failed for service \"%s\" at %s\n",
serviceName, p);
break;
}
- strcpy (*proxyAddress, p);
}
found = 1;
diff --git a/pmdb.c b/pmdb.c
index 2f046cc..a967367 100644
--- a/pmdb.c
+++ b/pmdb.c
@@ -76,14 +76,13 @@ FindProxyService (
if (!service)
return NULL;
- service->serviceName = (char *) malloc (nameLen + 1);
+ service->serviceName = strdup (serviceName);
if (!service->serviceName)
{
free (service);
return NULL;
}
- strcpy (service->serviceName, serviceName);
service->proxyCount = 0;
service->proxyList = NULL;
@@ -561,13 +560,13 @@ PushRequestorQueue (
if (!newreq)
return 0;
- newreq->serviceName = (char *) malloc (strlen (serviceName) + 1);
- newreq->serverAddress = (char *) malloc (strlen (serverAddress) + 1);
- newreq->hostAddress = (char *) malloc (strlen (hostAddress) + 1);
- newreq->startOptions = (char *) malloc (strlen (startOptions) + 1);
+ newreq->serviceName = strdup (serviceName);
+ newreq->serverAddress = strdup (serverAddress);
+ newreq->hostAddress = strdup (hostAddress);
+ newreq->startOptions = strdup (startOptions);
if (authLen > 0)
{
- newreq->authName = (char *) malloc (strlen (authName) + 1);
+ newreq->authName = strdup (authName);
newreq->authData = (char *) malloc (authLen);
}
else
@@ -595,13 +594,8 @@ PushRequestorQueue (
return 0;
}
- strcpy (newreq->serviceName, serviceName);
- strcpy (newreq->serverAddress, serverAddress);
- strcpy (newreq->hostAddress, hostAddress);
- strcpy (newreq->startOptions, startOptions);
if (authLen > 0)
{
- strcpy (newreq->authName, authName);
memcpy (newreq->authData, authData, authLen);
}