This is the mail archive of the
mailing list for the GDB project.
Re: [commit] cli/cli-decode.c (add_cmd): Add comment.
- From: Tom Tromey <tromey at redhat dot com>
- To: dje at google dot com (Doug Evans)
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 03 Oct 2011 11:52:58 -0600
- Subject: Re: [commit] cli/cli-decode.c (add_cmd): Add comment.
- References: <20110908173107.045DA2461B1@ruffy.mtv.corp.google.com>
>>>>> "Doug" == Doug Evans <email@example.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.