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.


> It's based on the observation that the objects that we save
> (registers and small memory writes) are frequently the size of
> a pointer (or smaller).  Therefore, instead of allocating both
> a pointer and some malloc memory to hold them, they can simply
> be saved in the space used for the pointer itself.

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

-- 
Joel


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