Always call NS_TraceMallocStartup if NS_TRACE_MALLOC is defined.

This commit is contained in:
brendan%mozilla.org 2000-05-31 02:01:23 +00:00
Родитель 1bed56cc6d
Коммит 2d47c77443
1 изменённых файлов: 6 добавлений и 7 удалений

Просмотреть файл

@ -1031,7 +1031,7 @@ static int
SetupMallocTracing(int argc, char* argv[]) SetupMallocTracing(int argc, char* argv[])
{ {
#ifdef NS_TRACE_MALLOC #ifdef NS_TRACE_MALLOC
int i; int i, logfd = -1;
/* /*
* Look for the --trace-malloc <logfile> option early, to avoid missing * Look for the --trace-malloc <logfile> option early, to avoid missing
@ -1042,10 +1042,9 @@ SetupMallocTracing(int argc, char* argv[])
{ {
if (PL_strcasecmp(argv[i], "--trace-malloc") == 0 && i < argc-1) { if (PL_strcasecmp(argv[i], "--trace-malloc") == 0 && i < argc-1) {
char *logfile; char *logfile;
int logfd, pipefds[2]; int pipefds[2];
logfile = argv[i+1]; logfile = argv[i+1];
logfd = -1;
switch (*logfile) { switch (*logfile) {
case '|': case '|':
if (pipe(pipefds) == 0) { if (pipe(pipefds) == 0) {
@ -1092,7 +1091,7 @@ SetupMallocTracing(int argc, char* argv[])
fprintf(stderr, fprintf(stderr,
"%s: can't pipe to trace-malloc child process %s: %s\n", "%s: can't pipe to trace-malloc child process %s: %s\n",
argv[0], logfile, strerror(errno)); argv[0], logfile, strerror(errno));
return 1; exit(1);
} }
break; break;
@ -1108,13 +1107,11 @@ SetupMallocTracing(int argc, char* argv[])
fprintf(stderr, fprintf(stderr,
"%s: can't create trace-malloc logfile %s: %s\n", "%s: can't create trace-malloc logfile %s: %s\n",
argv[0], logfile, strerror(errno)); argv[0], logfile, strerror(errno));
return 1; exit(1);
} }
break; break;
} }
NS_TraceMallocStartup(logfd);
/* Now remove --trace-malloc and its argument from argv. */ /* Now remove --trace-malloc and its argument from argv. */
for (argc -= 2; i < argc; i++) for (argc -= 2; i < argc; i++)
argv[i] = argv[i+2]; argv[i] = argv[i+2];
@ -1122,6 +1119,8 @@ SetupMallocTracing(int argc, char* argv[])
break; break;
} }
} }
NS_TraceMallocStartup(logfd);
#endif /* NS_TRACE_MALLOC */ #endif /* NS_TRACE_MALLOC */
return argc; return argc;