contrib/gdb-7/gdb/python/py-auto-load.c
static int
maybe_add_script (struct htab *htab, const char *name, const char *full_path)
{
  struct loaded_script **slot, entry;
  int in_hash_table;

  entry.name = name;
  entry.full_path = full_path;
  slot = (struct loaded_script **) htab_find_slot (htab, &entry, INSERT);
  in_hash_table = *slot != NULL;

  /* If this script is not in the hash table, add it.  */

  if (! in_hash_table)
    {
      char *p;

      /* Allocate all space in one chunk so it's easier to free.  */
      *slot = xmalloc (sizeof (**slot)
		       + strlen (name) + 1
		       + (full_path != NULL ? (strlen (full_path) + 1) : 0));
      p = ((char*) *slot) + sizeof (**slot);
      strcpy (p, name);
      (*slot)->name = p;
      if (full_path != NULL)
	{
	  p += strlen (p) + 1;
	  strcpy (p, full_path);
	  (*slot)->full_path = p;
	}
      else
	(*slot)->full_path = NULL;
    }

  return in_hash_table;
}
/* Add script NAME to hash table HTAB.
   FULL_PATH is NULL if the script wasn't found.
   The result is true if the script was already in the hash table.  */
Add script NAME to hash table HTAB.
FULL_PATH is NULL if the script wasn't found.
The result is true if the script was already in the hash table.
Add script NAME to hash table HTAB . FULL_PATH is NULL if the script wasn ' t found . The result is true if the script was already in the hash table .
static int
maybe_add_script (struct htab *htab, const char *name, const char *full_path)
{
  struct loaded_script **slot, entry;
  int in_hash_table;
  entry.name = name;
  entry.full_path = full_path;
  slot = (struct loaded_script **) htab_find_slot (htab, &entry, INSERT);
  in_hash_table = *slot != NULL;
  if (! in_hash_table)
    {
      char *p;
      *slot = xmalloc (sizeof (**slot)
		       + strlen (name) + 1
		       + (full_path != NULL ? (strlen (full_path) + 1) : 0));
      p = ((char*) *slot) + sizeof (**slot);
      strcpy (p, name);
      (*slot)->name = p;
      if (full_path != NULL)
	{
	  p += strlen (p) + 1;
	  strcpy (p, full_path);
	  (*slot)->full_path = p;
	}
      else
	(*slot)->full_path = NULL;
    }
  return in_hash_table;
}
static int maybe_add_script ( struct htab * htab , const char * name , const char * full_path ) { struct loaded_script * * slot , entry ; int in_hash_table ; entry . name = name ; entry . full_path = full_path ; slot = ( struct loaded_script * * ) htab_find_slot ( htab , & entry , INSERT ) ; in_hash_table = * slot != NULL ; if ( ! in_hash_table ) { char * p ; * slot = xmalloc ( sizeof ( * * slot ) + strlen ( name ) + 1 + ( full_path != NULL ? ( strlen ( full_path ) + 1 ) : 0 ) ) ; p = ( ( char * ) * slot ) + sizeof ( * * slot ) ; strcpy ( p , name ) ; ( * slot ) -> name = p ; if ( full_path != NULL ) { p += strlen ( p ) + 1 ; strcpy ( p , full_path ) ; ( * slot ) -> full_path = p ; } else ( * slot ) -> full_path = NULL ; } return in_hash_table ; }
Add script NAME to hash table HTAB.
Add script NAME to hash table HTAB .
/* If this script is not in the hash table, add it.  */ /* Allocate all space in one chunk so it's easier to free.  */