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] Prompt memory management/cleanups


Tom Tromey <tromey@redhat.com> writes:

>>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:
>
> Phil> While working on the Python patch to allow prompt substitution in
> Phil> Python, I noticed that in some cases prompts were leaking memory.  In
> Phil> several cases, scenarios like: PROMPT (0) = xstrdup(someprompt), did not
> Phil> xfree the prompt first.  I decided to use functions calls to replace
> Phil> access to PROMPT/SUFFIX/PREFIX so that memory management can be
> Phil> performed centrally.  Attached is a patch.  I'd appreciate comments on
> Phil> this; the testsuite shows no regressions, but my knowledge of the prompt
> Phil> area of GDB is about three days old. I'd especially like comments on the
> Phil> acceptance on NULL in the set_prompt/prefix/suffix functions.  Pop/push
> Phil> prompt uses different prompt levels and requires that, after use, they
> Phil> are cleaned.  It normally just does this with xfree.  I'm unsure if my
> Phil> API for that scenario is preferable.
>
> The patch seems fine, but I have a few questions.
>
> Does anything ever set the prefix or suffix to a non-empty value?
> I couldn't find an instance.  So how about just removing all this stuff
> instead?

The only use I can find is "", which may have meaning to the annotations
stuff.  This seems unlikely to me too.  If we think nobody uses it or is
likely to use it in the future, we can declare those elements dead, and
just remove them?

> Do we still need the PROMPT, PREFIX, and SUFFIX defines in event-top.h?

No.  They should not be accessible except from top.c and event-top.c
anymore. So I will remove them.

Cheers,

Phil


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