This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [rfc] Plug memory leaks during gdbarch initialization


Daniel Jacobowitz <drow@false.org> writes:
> The patch is an improvement, but doesn't fix that wart.  I don't really
> want to check it in without fixing the underlying problem but I don't
> see a good way... anyone have a suggestion?

I could imagine having each file's _initialize function start with:

void
_initialize_foo (void)
{
  static initialized;

  if (initialized)
    return;
  initialized = 1;

  ...
}

A sed script could get the job done.  Then, they could call each other
with wild abandon.  For extra points, you could do:

void
_initialize_foo (void)
{
  static int initialized;

  assert (initialized != 1);
  if (initialized)
    return;
  initialized = 1;

  ...

  initialized = 2;
}

So you'd catch circular dependencies.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]