[Python-checkins] r80742 - python/trunk/Modules/readline.c
Brett Cannon
brett at python.org
Tue May 4 22:03:36 CEST 2010
On Tue, May 4, 2010 at 01:34, Victor Stinner
<victor.stinner at haypocalc.com>wrote:
> Le mardi 04 mai 2010 02:52:42, brett.cannon a écrit :
> > Author: brett.cannon
> > New Revision: 80742
> >
> > Log:
> > Strip out extraneous whitespace, cast a some `const char *` to `void *`
> > when passed to free() and make a `char *` to a `const char *` as found
> by
> > Clang's static analyzer.
>
> On my version of readline (6.1), HIST_ENTRY has no const field:
>
> typedef struct _hist_entry {
> char *line;
> char *timestamp; /* char * rather than time_t for read/write
> */
> histdata_t data;
> } HIST_ENTRY;
>
> Is it different in your version of readline?
>
I'm on OS X, so I think I might be linking against libedit. Either way the
cast shouldn't harm anything as the char* pointer contents are not modified
in any way by the function. Is the cast triggering a compiler warning for
you?
-Brett
>
> > Modified:
> > python/trunk/Modules/readline.c
> >
> > @@ -378,7 +378,7 @@
> > }
> > /* free memory allocated for the history entry */
> > if (entry->line)
> > - free(entry->line);
> > + free((void *)entry->line);
> > if (entry->data)
> > free(entry->data);
> > free(entry);
> > @@ -415,7 +415,7 @@
> > }
> > /* free memory allocated for the old history entry */
> > if (old_entry->line)
> > - free(old_entry->line);
> > + free((void *)old_entry->line);
> > if (old_entry->data)
> > free(old_entry->data);
> > free(old_entry);
>
> ...
>
> > @@ -1023,17 +1023,17 @@
> > /* we have a valid line */
> > n = strlen(p);
> > if (n > 0) {
> > - char *line;
> > + const char *line;
> > HISTORY_STATE *state = history_get_history_state();
> > if (state->length > 0)
> > #ifdef __APPLE__
>
> --
> Victor Stinner
> http://www.haypocalc.com/
> _______________________________________________
> Python-checkins mailing list
> Python-checkins at python.org
> http://mail.python.org/mailman/listinfo/python-checkins
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-checkins/attachments/20100504/538aa82c/attachment.html>
More information about the Python-checkins
mailing list