- struct gdb_block *block = XCNEW (struct gdb_block);
-
- block->next = symtab->blocks;
- block->begin = (CORE_ADDR) begin;
- block->end = (CORE_ADDR) end;
- block->name = name ? xstrdup (name) : NULL;
- block->parent = parent;
-
- /* Ensure that the blocks are inserted in the correct (reverse of
- the order expected by blockvector). */
- if (compare_block (symtab->blocks, block))
- {
- symtab->blocks = block;
- }
- else
- {
- struct gdb_block *i = symtab->blocks;
-
- for (;; i = i->next)
- {
- /* Guaranteed to terminate, since compare_block (NULL, _)
- returns 1. */
- if (compare_block (i->next, block))
- {
- block->next = i->next;
- i->next = block;
- break;
- }
- }
- }
+ /* Place the block at the beginning of the list, it will be sorted when the
+ symtab is finalized. */
+ symtab->blocks.emplace_front (parent, begin, end, name);