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]

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


Hi.

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

I think the right fix is to either have add_cmd xstrdup NAME and DOC,
or (for completeness sake) extend the CLI API to allow specifying
whether NAME,DOC need to be freed.
Otherwise we can leak memory if a command is deleted/replaced.
The former is obviously simpler and cleaner, but I don't know
if anyone will object to it.  We could of course just ignore the problem
until it becomes an issue - I'm in no rush to see it fixed.

2011-09-08  Doug Evans  <dje@google.com>

	* cli/cli-decode.c (add_cmd): Add comment.

Index: cli/cli-decode.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-decode.c,v
retrieving revision 1.96
diff -u -p -r1.96 cli-decode.c
--- cli/cli-decode.c	4 Aug 2011 19:10:13 -0000	1.96
+++ cli/cli-decode.c	8 Sep 2011 16:55:07 -0000
@@ -128,6 +128,7 @@ set_cmd_completer (struct cmd_list_eleme
 
 
 /* Add element named NAME.
+   Space for NAME and DOC must be allocated by the caller.
    CLASS is the top level category into which commands are broken down
    for "help" purposes.
    FUN should be the function to execute the command;


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