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 5/7] go32-nat.c: Don't install a deprecated_xfer_memory method


(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


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