[RFA] record.c - save some memory in record log.
Hui Zhu
teawater@gmail.com
Sun Oct 18 01:53:00 GMT 2009
>
> One way that we have used in the past that might be helpful here
> is to define the buffer at the end of the structure and without
> the pointer indirection:
>
> struct blah
> {
> ...
>
> int buffer_len;
> gdb_byte buf[0];
> };
>
> The allocation of the structure become a little trickier. And access
> to the buffer is a little more dangerous, which is why I don't like
> this approach much. But it does save memory, and you can prevent
> buffer overrun by forcing access to this data through accessor
> routines...
>
Hi Joel,
But I think:
+ union
+ {
+ gdb_byte *ptr;
+ gdb_byte buf[2 * sizeof (gdb_byte *)];
Make the size of buf more clear.
Thanks,
Hui
More information about the Gdb-patches
mailing list