This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 5/7] go32-nat.c: Don't install a deprecated_xfer_memory method
- From: Pedro Alves <palves at redhat dot com>
- To: Pierre Muller <pierre dot muller at ics-cnrs dot unistra dot fr>, GDB Patches <gdb-patches at sourceware dot org>
- Date: Thu, 20 Feb 2014 16:36:55 +0000
- Subject: Re: [PATCH 5/7] go32-nat.c: Don't install a deprecated_xfer_memory method
- Authentication-results: sourceware.org; auth=none
- References: <1392841775-19126-1-git-send-email-palves at redhat dot com> <1392841775-19126-6-git-send-email-palves at redhat dot com> <00c801cf2e59$acae60f0$060b22d0$ at muller@ics-cnrs.unistra.fr>
(adding back gdb-patches@)
On 02/20/2014 04:34 PM, Pierre Muller wrote:
> I found something that looks suspicious in your patch...
> But once again, it could be my lack of proper C formation...
>
>> +/* Const-correct version of DJGPP's write_child, which unfortunately
>> + takes a non-const buffer pointer. */
>> +
>> static int
>> +my_write_child (unsigned child_addr, const void *buf, unsigned len)
>> {
>> - if (write)
>> + static void *buffer = NULL;
>> + static unsigned buffer_len = 0;
> It seems odd to me to use
> a static variable buffer_len, which keeps the size
> of the last allocated buffer, when you do
> a xfree before returning from this function...
>
>> + int res;
>> +
>> + if (buffer_len < len)
>> {
>> - if (write_child (memaddr, myaddr, len))
>> - {
>> - return 0;
>> - }
>> - else
>> - {
>> - return len;
>> - }
>> + buffer = xrealloc (buffer, len);
>> + buffer_len = len;
>> }
>> +
>> + memcpy (buffer, buf, len);
>> + res = write_child (child_addr, buffer, len);
>> + xfree (buffer);
> This line should be removed, or did I miss something?
You're right. I'll remove it. Thanks!
--
Pedro Alves