[RFA] record.c - save some memory in record log.

Michael Snyder msnyder@vmware.com
Sun Oct 18 16:14:00 GMT 2009


Joel Brobecker wrote:
>> But I think:
> 
> Note that I was just idly mentioning a trick I saw us use in the past,
> but it's definitely ok if you guys think it's a bad idea.
> 
>> +  union
>> +  {
>> +    gdb_byte *ptr;
>> +    gdb_byte buf[2 * sizeof (gdb_byte *)];
>>
>> Make the size of buf more clear.
> 
> The problem with this approach is that the size of the union is the
> maximum of all its components.  So the size of your union is always
> going to be 8/16 bytes, depending on whether addresses are 4 or 8 bytes.
> Unless buf was meant to be a 2-bytes buffer, then the size is always
> going to be 4 bytes.
> 
> With the trick I provided, the size is always going to be exactly as
> much as you need.  But, like I said, it's not exactly super clean...
> 

Joel, it's a work in progress.  ;-)

I see the change I made as having made the data structure
incrementally better.  There's always room for a further change
that makes it better still.




More information about the Gdb-patches mailing list