diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-09-30 20:19:44 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-09-30 20:19:44 -0700 |
commit | a70f4e6f7243e9e6803b3308a15c9cf3a77ee383 (patch) | |
tree | 82c3edcd4782025d8230d120688e0cbb4ebf3e4d | |
parent | 37092d5ae31fa53c9a2f378786bfebe26e04c030 (diff) | |
download | xscope-a70f4e6f7243e9e6803b3308a15c9cf3a77ee383.tar.gz |
Ensure ScopeHost global is initialized when built with USE_XTRANS
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
-rw-r--r-- | common.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -200,9 +200,15 @@ SetUpConnectionSocket( struct linger linger; #endif /* SO_DONTLINGER */ #endif + char MyHostName[256]; enterprocedure("SetUpConnectionSocket"); + (void) gethostname(MyHostName, sizeof(MyHostName)); + ScopeHost = strdup(MyHostName); + if (ScopeHost == NULL) + panic("Can't allocate memory for hostname"); + #ifdef USE_XTRANS ScopePort = iport - ServerBasePort; sprintf (port, "%d", ScopePort); @@ -258,14 +264,7 @@ SetUpConnectionSocket( */ { /* define the host part of the address */ - char MyHostName[256]; - struct hostent *hp; - - (void) gethostname(MyHostName, sizeof(MyHostName)); - ScopeHost = strdup(MyHostName); - if (ScopeHost == NULL) - panic("Can't allocate memory for hostname"); - hp = gethostbyname(MyHostName); + struct hostent *hp = gethostbyname(MyHostName); if (hp == NULL) panic("No address for our host"); bcopy((char *)hp->h_addr, (char*)&sin.sin_addr, hp->h_length); |