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.


>
> 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


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