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: [PATCH] solib_open, memory leak


[Jim:]
> The code clearly deserves a comment like:
>
>     /* We try to find the library in various ways.  After each
>        attempt, either found_file >= 0 and temp_pathname is a malloc'd
>        string, or found_file < 0 and temp_pathname does not point to
>        storage that needs to be freed.  */
>
> In that light, it seems clearer to me to just put:
>
>    if (found_file < 0)
>      temp_pathname = NULL;
>    else
>      temp_pathname = xstrdup (temp_pathname);
>
> immediately after the open, to make it obvious that the rule is
> followed there.
>
[...]
> Don't you want those new lines to replace the two that followed them,
> not just precede them?

Yes, thanks.  How about this?

Attachment: solib_open2.txt
Description: Text document


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