diff options
Diffstat (limited to 'src/or/ntmain.c')
-rw-r--r-- | src/or/ntmain.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/src/or/ntmain.c b/src/or/ntmain.c index 985fab73c..bd07df1b3 100644 --- a/src/or/ntmain.c +++ b/src/or/ntmain.c @@ -193,7 +193,6 @@ nt_service_loadlibrary(void) */ int nt_service_is_stopping(void) -/* XXXX this function would probably _love_ to be inline, in 0.2.0. */ { /* If we haven't loaded the function pointers, we can't possibly be an NT * service trying to shut down. */ @@ -457,9 +456,9 @@ nt_service_command_line(int *using_default_torrc) { TCHAR tor_exe[MAX_PATH+1]; char tor_exe_ascii[MAX_PATH+1]; - char *command, *options=NULL; + char *command=NULL, *options=NULL; smartlist_t *sl; - int i, cmdlen; + int i; *using_default_torrc = 1; /* Get the location of tor.exe */ @@ -467,7 +466,7 @@ nt_service_command_line(int *using_default_torrc) return NULL; /* Get the service arguments */ - sl = smartlist_create(); + sl = smartlist_new(); for (i = 1; i < backup_argc; ++i) { if (!strcmp(backup_argv[i], "--options") || !strcmp(backup_argv[i], "-options")) { @@ -488,21 +487,13 @@ nt_service_command_line(int *using_default_torrc) strlcpy(tor_exe_ascii, tor_exe, sizeof(tor_exe_ascii)); #endif - /* Allocate a string for the NT service command line */ - cmdlen = strlen(tor_exe_ascii) + (options?strlen(options):0) + 32; - command = tor_malloc(cmdlen); - + /* Allocate a string for the NT service command line and */ /* Format the service command */ if (options) { - if (tor_snprintf(command, cmdlen, "\"%s\" --nt-service \"%s\"", - tor_exe_ascii, options)<0) { - tor_free(command); /* sets command to NULL. */ - } + tor_asprintf(&command, "\"%s\" --nt-service \"%s\"", + tor_exe_ascii, options); } else { /* ! options */ - if (tor_snprintf(command, cmdlen, "\"%s\" --nt-service", - tor_exe_ascii)<0) { - tor_free(command); /* sets command to NULL. */ - } + tor_asprintf(&command, "\"%s\" --nt-service", tor_exe_ascii); } tor_free(options); |