Skip to content

Commit 70bf144

Browse files
committed
Bug 1255655 - Heap-allocate _progname. r=froydnj.
This saves almost 1 KiB per process. --HG-- extra : rebase_source : 56e7d9451b0c647b1672dc23e6bc1117c5a20388
1 parent 755a8e0 commit 70bf144

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

toolkit/xre/nsSigHandlers.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#include <ucontext.h>
3838
#endif
3939

40-
static char _progname[1024] = "huh?";
40+
static const char* gProgname = "huh?";
4141

4242
// Note: some tests manipulate this value.
4343
unsigned int _gdb_sleep_duration = 300;
@@ -84,7 +84,7 @@ void
8484
ah_crap_handler(int signum)
8585
{
8686
printf("\nProgram %s (pid = %d) received signal %d.\n",
87-
_progname,
87+
gProgname,
8888
getpid(),
8989
signum);
9090

@@ -94,7 +94,7 @@ ah_crap_handler(int signum)
9494

9595
printf("Sleeping for %d seconds.\n",_gdb_sleep_duration);
9696
printf("Type 'gdb %s %d' to attach your debugger to this thread.\n",
97-
_progname,
97+
gProgname,
9898
getpid());
9999

100100
// Allow us to be ptraced by gdb on Linux with Yama restrictions enabled.
@@ -227,9 +227,12 @@ static void fpehandler(int signum, siginfo_t *si, void *context)
227227
}
228228
#endif
229229

230-
void InstallSignalHandlers(const char *ProgramName)
230+
void InstallSignalHandlers(const char *aProgname)
231231
{
232-
PL_strncpy(_progname,ProgramName, (sizeof(_progname)-1) );
232+
const char* tmp = PL_strdup(aProgname);
233+
if (tmp) {
234+
gProgname = tmp;
235+
}
233236

234237
const char *gdbSleep = PR_GetEnv("MOZ_GDB_SLEEP");
235238
if (gdbSleep && *gdbSleep)
@@ -383,14 +386,14 @@ LONG __stdcall FpeHandler(PEXCEPTION_POINTERS pe)
383386
return action;
384387
}
385388

386-
void InstallSignalHandlers(const char *ProgramName)
389+
void InstallSignalHandlers(const char *aProgname)
387390
{
388391
gFPEPreviousFilter = SetUnhandledExceptionFilter(FpeHandler);
389392
}
390393

391394
#else
392395

393-
void InstallSignalHandlers(const char *ProgramName)
396+
void InstallSignalHandlers(const char *aProgname)
394397
{
395398
}
396399

0 commit comments

Comments
 (0)