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: [RFA] record.c - save some memory in record log.


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.



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