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

Joel Brobecker brobecker@adacore.com
Sun Oct 18 16:10:00 GMT 2009


> 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



More information about the Gdb-patches mailing list