diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-01-13 00:04:32 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-01-20 23:29:28 -0800 |
commit | d5d409ac7b5792f3962dbe8a7f392d09ce797266 (patch) | |
tree | e365d376163d37b270ee592e892dc093892f1336 /xsm.c | |
parent | 00c7550444aa1254ca43ba32d4d4e59d02bda56d (diff) |
Convert XtMalloc + sprintf to XtAsprintf
Depends on libXt > 1.0.99 to ensure XtAsprintf is available.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'xsm.c')
-rw-r--r-- | xsm.c | 26 |
1 files changed, 6 insertions, 20 deletions
@@ -257,9 +257,7 @@ main(int argc, char *argv[]) /* the sizeof includes the \0, so we don't need to count the '=' */ networkIds = IceComposeNetworkIdList (numTransports, listenObjs); - p = (char *) XtMalloc((sizeof environment_name) + strlen(networkIds) + 1); - if(!p) nomem(); - sprintf(p, "%s=%s", environment_name, networkIds); + XtAsprintf(&p, "%s=%s", environment_name, networkIds); putenv(p); if (cmd_line_display) @@ -270,8 +268,7 @@ main(int argc, char *argv[]) * the session manager will run on the specified display. */ - p = (char *) XtMalloc(8 + strlen(cmd_line_display) + 1); - sprintf(p, "DISPLAY=%s", cmd_line_display); + XtAsprintf(&p, "DISPLAY=%s", cmd_line_display); putenv(p); } @@ -428,9 +425,7 @@ GetEnvironment(void) display_env = NULL; if((p = cmd_line_display) || (p = (char *) getenv(envDISPLAY))) { - display_env = (char *) XtMalloc(strlen(envDISPLAY)+1+strlen(p)+1); - if(!display_env) nomem(); - sprintf(display_env, "%s=%s", envDISPLAY, p); + XtAsprintf(&display_env, "%s=%s", envDISPLAY, p); /* * When we restart a remote client, we have to make sure the @@ -457,21 +452,14 @@ GetEnvironment(void) char hostnamebuf[256]; gethostname (hostnamebuf, sizeof hostnamebuf); - non_local_display_env = (char *) XtMalloc ( - strlen (envDISPLAY) + 1 + - strlen (hostnamebuf) + strlen (temp) + 1); - if (!non_local_display_env) nomem(); - sprintf(non_local_display_env, "%s=%s%s", + XtAsprintf(&non_local_display_env, "%s=%s%s", envDISPLAY, hostnamebuf, temp); } } session_env = NULL; if((p = (char *) getenv(envSESSION_MANAGER))) { - session_env = (char *) XtMalloc( - strlen(envSESSION_MANAGER)+1+strlen(p)+1); - if(!session_env) nomem(); - sprintf(session_env, "%s=%s", envSESSION_MANAGER, p); + XtAsprintf(&session_env, "%s=%s", envSESSION_MANAGER, p); /* * When we restart a remote client, we have to make sure the @@ -507,9 +495,7 @@ GetEnvironment(void) audio_env = NULL; if((p = (char *) getenv(envAUDIOSERVER))) { - audio_env = (char *) XtMalloc(strlen(envAUDIOSERVER)+1+strlen(p)+1); - if(!audio_env) nomem(); - sprintf(audio_env, "%s=%s", envAUDIOSERVER, p); + XtAsprintf(&audio_env, "%s=%s", envAUDIOSERVER, p); } } |