[interfacekit] Re: [Fwd: Undelivered Mail Returned to Sender]
- From: Erik Jaesler <erik@xxxxxxxxxxx>
- To: interfacekit@xxxxxxxxxxxxx
- Date: Mon, 03 Nov 2003 11:15:34 -0800
Alan's having issues getting mail through to the list, so here's a forward.
e
Alan Westbrook wrote:
Erik Jaesler wrote:
Oliver Tappe wrote:
Rather than removing the strcmp() test, I would much rather see
_GrowBy() initialize new space to '\0'. Since a default-constructed
BString is otherwise ready for use, it seems inconsistent that
LockBuffer() can return something that isn't. As it is, if I have
BString myString("test");
myString.LockBuffer(10);
_GrowBy() is going to leave me with "test\0xxxxx\0" (where 'x' is
random cruft), which is not very hygenic. ;) So making the suggested
change will not only give predictable results for default-constructed
BStrings, but just be generally more clean. Depending on what the use
cases are, it might be a good idea to apply this to _OpenAtBy() as well.
Not initializing it to zeros is a performance feature. Assuming that you
are using LockBuffer() to access the char* for performance reasons, it
seems a little counterproductive to do this.
How about just making sure that the string in null terminated before
causing it to grow.
Alan
Other related posts:
- » [interfacekit] Re: [Fwd: Undelivered Mail Returned to Sender]
Oliver Tappe wrote:
Rather than removing the strcmp() test, I would much rather see _GrowBy() initialize new space to '\0'. Since a default-constructed BString is otherwise ready for use, it seems inconsistent that LockBuffer() can return something that isn't. As it is, if I have
BString myString("test"); myString.LockBuffer(10);
_GrowBy() is going to leave me with "test\0xxxxx\0" (where 'x' is random cruft), which is not very hygenic. ;) So making the suggested change will not only give predictable results for default-constructed BStrings, but just be generally more clean. Depending on what the use cases are, it might be a good idea to apply this to _OpenAtBy() as well.
Not initializing it to zeros is a performance feature. Assuming that you are using LockBuffer() to access the char* for performance reasons, it seems a little counterproductive to do this.
How about just making sure that the string in null terminated before causing it to grow.
Alan