< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index Next in Thread >

Re: [reSIProcate] Compilation error in latest code



On Nov 20, 2004, at 18:33, david Butcher wrote:

[snip]
Thanks for the vote of confidence :-)
Data does not depend on intialization of the memory. Only the terminal null
matters, and then only if you use c_str().


Just wanted to be 100% sure. :-) Nothing intended to be implied.

2. Generalized the Take/Share enum to include Borrow. Borrow is used to
indicate that the Data is using a writable but not owned buffer.
Borrow is used
to indicate that the internal buffer is being used. Borrow also allows
Datas to
be created that use stack memory rather than heap memory.


I 'take' it that you also implemented the behaviour described? Any
issues or use notes that might affect or benefit other Data users?

Implemented. There is no legacy impact. The internals of Data are a little
cleaner. Here is a use case:

{
  ...
  char buffer[8192];
  Data tmp(Data::Borrow, buffer, sizeof(buffer));
  // use tmp as usual -- tmp will still grow as necessary
  ...
} // buffer deallocated by scope end

I can't recommend wholesale use of this idiom, but it may be useful in inner loops etc. I have not tried to apply it to the stack proper -- mostly 'Shares'
there.


Actually that's not too bad and might make a strong case for removing the complicated frame-local initial buffer code from Data. What do you think?
Then again, maybe not -- any thoughts on this matter?

A


a l a n a t j a s o m i d o t c o m