diff options
Diffstat (limited to 'gdb/xcoffread.c')
-rw-r--r-- | gdb/xcoffread.c | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 50a3e29..a40aa8f 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -400,6 +400,7 @@ static int inclIndx; /* last entry to table */ static int inclLength; /* table length */ static int inclDepth; /* nested include depth */ +static void allocate_include_entry PARAMS ((void)); static void record_include_begin (cs) @@ -418,27 +419,12 @@ struct coff_symbol *cs; } ++inclDepth; - /* allocate an include file, or make room for the new entry */ - if (inclLength == 0) { - inclTable = (InclTable*) - xmalloc (sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH); - memset (inclTable, '\0', sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH); - inclLength = INITIAL_INCLUDE_TABLE_LENGTH; - inclIndx = 0; - } - else if (inclIndx >= inclLength) { - inclLength += INITIAL_INCLUDE_TABLE_LENGTH; - inclTable = (InclTable*) - xrealloc (inclTable, sizeof (InclTable) * inclLength); - memset (inclTable+inclLength-INITIAL_INCLUDE_TABLE_LENGTH, - '\0', sizeof (InclTable)*INITIAL_INCLUDE_TABLE_LENGTH); - } + allocate_include_entry (); inclTable [inclIndx].name = cs->c_name; inclTable [inclIndx].begin = cs->c_value; } - static void record_include_end (cs) struct coff_symbol *cs; @@ -451,6 +437,8 @@ struct coff_symbol *cs; complain (&msg); } + allocate_include_entry (); + pTbl = &inclTable [inclIndx]; pTbl->end = cs->c_value; @@ -458,9 +446,30 @@ struct coff_symbol *cs; ++inclIndx; } +static void +allocate_include_entry () +{ + if (inclTable == NULL) + { + inclTable = (InclTable *) + xmalloc (sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH); + memset (inclTable, + '\0', sizeof (InclTable) * INITIAL_INCLUDE_TABLE_LENGTH); + inclLength = INITIAL_INCLUDE_TABLE_LENGTH; + inclIndx = 0; + } + else if (inclIndx >= inclLength) + { + inclLength += INITIAL_INCLUDE_TABLE_LENGTH; + inclTable = (InclTable *) + xrealloc (inclTable, sizeof (InclTable) * inclLength); + memset (inclTable + inclLength - INITIAL_INCLUDE_TABLE_LENGTH, + '\0', sizeof (InclTable)*INITIAL_INCLUDE_TABLE_LENGTH); + } +} -/* given the start and end addresses of a compilation unit (or a csect, at times) - process its lines and create appropriate line vectors. */ +/* given the start and end addresses of a compilation unit (or a csect, + at times) process its lines and create appropriate line vectors. */ static void process_linenos (start, end) |