[PATCH:xscope 05/14] Use strdup instead of malloc(strlen+1); strcpy();
Alan Coopersmith
alan.coopersmith at ORACLE.COM
Sat Sep 24 08:48:23 PDT 2011
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
common.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/common.c b/common.c
index 1baf288..42220cd 100644
--- a/common.c
+++ b/common.c
@@ -262,10 +262,9 @@ SetUpConnectionSocket(
struct hostent *hp;
(void) gethostname(MyHostName, sizeof(MyHostName));
- ScopeHost = malloc((1+strlen(MyHostName)));
+ ScopeHost = strdup(MyHostName);
if (ScopeHost == NULL)
panic("Can't allocate memory for hostname");
- strcpy(ScopeHost, MyHostName);
hp = gethostbyname(MyHostName);
if (hp == NULL)
panic("No address for our host");
--
1.7.3.2
More information about the xorg-devel
mailing list