contrib/libg++-2.3/libiberty/strsignal.c
/*

NAME

	init_signal_tables -- initialize the name and message tables

SYNOPSIS

	static void init_signal_tables ();

DESCRIPTION

	Using the signal_table, which is initialized at compile time, generate
	the signal_names and the sys_siglist (if needed) tables, which are
	indexed at runtime by a specific signal value.

BUGS

	The initialization of the tables may fail under low memory conditions,
	in which case we don't do anything particularly useful, but we don't
	bomb either.  Who knows, it might succeed at a later point if we free
	some memory in the meantime.  In any case, the other routines know
	how to deal with lack of a table after trying to initialize it.  This
	may or may not be considered to be a bug, that we don't specifically
	warn about this particular failure mode.

*/
NAME
init_signal_tables -- initialize the name and message tables

SYNOPSIS

static void init_signal_tables ().

DESCRIPTION

Using the signal_table, which is initialized at compile time, generate
the signal_names and the sys_siglist (if needed) tables, which are
indexed at runtime by a specific signal value.

BUGS

The initialization of the tables may fail under low memory conditions,
in which case we don't do anything particularly useful, but we don't
bomb either.  Who knows, it might succeed at a later point if we free
some memory in the meantime.  In any case, the other routines know
how to deal with lack of a table after trying to initialize it.  This
may or may not be considered to be a bug, that we don't specifically
warn about this particular failure mode.
NAME init_signal_tables -- initialize the name and message tables SYNOPSIS static void init_signal_tables () . DESCRIPTION Using the signal_table which is initialized at compile time generate the signal_names and the sys_siglist ( if needed ) tables which are indexed at runtime by a specific signal value . BUGS The initialization of the tables may fail under low memory conditions in which case we don ' t do anything particularly useful but we don ' t bomb either . Who knows it might succeed at a later point if we free some memory in the meantime . In any case the other routines know how to deal with lack of a table after trying to initialize it . This may or may not be considered to be a bug that we don ' t specifically warn about this particular failure mode .
static void
init_signal_tables ()
{
  struct signal_info *eip;
  int nbytes;
  if (num_signal_names == 0)
    {
      for (eip = signal_table; eip -> name != NULL; eip++)
	{
	  if (eip -> value >= num_signal_names)
	    {
	      num_signal_names = eip -> value + 1;
	    }
	}
    }
  if (signal_names == NULL)
    {
      nbytes = num_signal_names * sizeof (char *);
      if ((signal_names = (char **) malloc (nbytes)) != NULL)
	{
	  memset (signal_names, 0, nbytes);
	  for (eip = signal_table; eip -> name != NULL; eip++)
	    {
	      signal_names[eip -> value] = eip -> name;
	    }
	}
    }
#ifdef NEED_sys_siglist
  if (sys_siglist == NULL)
    {
      nbytes = num_signal_names * sizeof (char *);
      if ((sys_siglist = (char **) malloc (nbytes)) != NULL)
	{
	  memset (sys_siglist, 0, nbytes);
	  sys_nsig = num_signal_names;
	  for (eip = signal_table; eip -> name != NULL; eip++)
	    {
	      sys_siglist[eip -> value] = eip -> msg;
	    }
	}
    }
#endif
}
static void init_signal_tables ( ) { struct signal_info * eip ; int nbytes ; if ( num_signal_names == 0 ) { for ( eip = signal_table ; eip -> name != NULL ; eip ++ ) { if ( eip -> value >= num_signal_names ) { num_signal_names = eip -> value + 1 ; } } } if ( signal_names == NULL ) { nbytes = num_signal_names * sizeof ( char * ) ; if ( ( signal_names = ( char * * ) malloc ( nbytes ) ) != NULL ) { memset ( signal_names , 0 , nbytes ) ; for ( eip = signal_table ; eip -> name != NULL ; eip ++ ) { signal_names [ eip -> value ] = eip -> name ; } } } #ifdef NEED_sys_siglist if ( sys_siglist == NULL ) { nbytes = num_signal_names * sizeof ( char * ) ; if ( ( sys_siglist = ( char * * ) malloc ( nbytes ) ) != NULL ) { memset ( sys_siglist , 0 , nbytes ) ; sys_nsig = num_signal_names ; for ( eip = signal_table ; eip -> name != NULL ; eip ++ ) { sys_siglist [ eip -> value ] = eip -> msg ; } } } #endif }
NAME
init_signal_tables -- initialize the name and message tables
NAME init_signal_tables -- initialize the name and message tables
/* If we haven't already scanned the signal_table once to find the maximum
     signal value, then go find it now. */ /* Now attempt to allocate the signal_names table, zero it out, and then
     initialize it from the statically initialized signal_table. */ /* Now attempt to allocate the sys_siglist table, zero it out, and then
     initialize it from the statically initialized signal_table. */