Re: [PATCH 2/2] Free multidicts from blockvector

Tom Tromey
2025-10-24T14:13:07Z

Simon> Ideally it would be struct block's just to call that. You could add a
Simon> destructor to struct block and call it explicitly here. It would be the
Simon> same result, but would be more correct encapsulation-wise. But I guess
Simon> this is fine too for the time being.

Tom> Yeah. I have kind of an aversion to explicit destructor calls.
Tom> Though maybe not for any good reason.

I was thinking about this last night and realized there's a bigger
issue, which is that blocks are allocated on an obstack:

struct block : public allocate_on_obstack<block>

and

block = new (&m_objfile->objfile_obstack) struct block;

but allocate_on_obstack requires that the object be trivially
destructible.

Maybe this could be remedied by resurrecting Jan's obstack allocator;
making an "obstack_ptr" class that explicitly calls the destructor but
not 'delete'; and finally changing blockvector to hold these.

Tom