{
/* Next set of slots for this file. */
struct stab_types *next;
+ /* Where the TYPES array starts. */
+ unsigned int base_index;
/* Types indexed by type number. */
#define STAB_TYPES_SLOTS (16)
debug_type types[STAB_TYPES_SLOTS];
static debug_type *
stab_find_slot (struct stab_handle *info, const int *typenums)
{
- int filenum;
- int tindex;
+ unsigned int filenum;
+ unsigned int tindex;
+ unsigned int base_index;
struct stab_types **ps;
filenum = typenums[0];
tindex = typenums[1];
- if (filenum < 0 || (unsigned int) filenum >= info->files)
+ if (filenum >= info->files)
{
fprintf (stderr, _("Type file number %d out of range\n"), filenum);
return NULL;
}
- if (tindex < 0)
- {
- fprintf (stderr, _("Type index number %d out of range\n"), tindex);
- return NULL;
- }
ps = info->file_types + filenum;
+ base_index = tindex / STAB_TYPES_SLOTS * STAB_TYPES_SLOTS;
+ tindex -= base_index;
+ while (*ps && (*ps)->base_index < base_index)
+ ps = &(*ps)->next;
- while (tindex >= STAB_TYPES_SLOTS)
- {
- if (*ps == NULL)
- {
- *ps = (struct stab_types *) xmalloc (sizeof **ps);
- memset (*ps, 0, sizeof **ps);
- }
- ps = &(*ps)->next;
- tindex -= STAB_TYPES_SLOTS;
- }
- if (*ps == NULL)
+ if (*ps == NULL || (*ps)->base_index != base_index)
{
- *ps = (struct stab_types *) xmalloc (sizeof **ps);
- memset (*ps, 0, sizeof **ps);
+ struct stab_types *n = xcalloc (1, sizeof (*n));
+ n->next = *ps;
+ n->base_index = base_index;
+ *ps = n;
}
return (*ps)->types + tindex;