[commit] cli/cli-decode.c (add_cmd): Add comment.

Tom Tromey tromey@redhat.com
Mon Oct 3 17:53:00 GMT 2011


>>>>> "Doug" == Doug Evans <dje@google.com> writes:

Doug> I have checked in this hopefully temporary patch to document
Doug> that it's the caller's responsibility to allocate space for
Doug> NAME and DOC to add_cmd().

Doug> I think the right fix is to either have add_cmd xstrdup NAME and DOC,
Doug> or (for completeness sake) extend the CLI API to allow specifying
Doug> whether NAME,DOC need to be freed.
Doug> Otherwise we can leak memory if a command is deleted/replaced.
Doug> The former is obviously simpler and cleaner, but I don't know
Doug> if anyone will object to it.

I think it depends on the measured cost of the change.  Right now most
of the name and doc strings are compile-time constants.  Changing this
would mean a bunch of allocations at startup.

Tom



More information about the Gdb-patches mailing list