The new string file worked great. thanks! bill "Ben Combee" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > At 16:42 2003-3-19 -0800, you wrote: > >After some futher testing and stepping through the code, we've noticed that > >when the string::t0 is copied from another string::t0 that the full > >string::t2 structure was not copied, therfore missing the final element of > >string::t2.data_ (null term character) So whatever information that was > >there prior to the copy, it stayed there (in some cases a luck null char, > >other times a random byte). > > > >After surround the two structures with a pragma pack 1 (since the short_size > >is a bit field), it seems to have fixed the problem. Now my problem is > >(basically UI in the debugger or some existing type library that is being > >used by the debugger) that when viewing this data in the debug watch window, > >the short_size structure still appears as two bytes. therefore making it > >appear as if I have truncated the start of my data_, but when you look in > >memory, all is well. (hence if I set a lpcstr to the string.c_str() of this > >object, the value is correct.). > > > >Is there anything I can do to correct the debugger problem? > >Any help would be Greatly! appreciated.. > > Hmmm... this version of STL was developed on 32-bit machines (Win32 and Mac > OS PowerPC), so its possible that the 16-bit int case wasn't tested > well. I think I've found the bug in the code, thanks to your helpful > diagnosis. > > The basic_string union is defined raw_t, short_t, and long_t. > > static const size_type n_words = sizeof(short_t) > sizeof(long_t) ? > sizeof(short_t) / > sizeof(size_type) : > sizeof(long_t) / > sizeof(size_type); > > struct raw_t > { > size_type words_[n_words]; > }; > > The problem is that division rounds down, so the size of raw_t may be too > small. size_type is 32-bits, but if the larger of the short_t and long_t > structures isn't evenly divisible by 32-bits, then raw_t will be defined > too small. > > The solution: change the n_words definition to be: > > static const size_type n_words = sizeof(short_t) > sizeof(long_t) ? > (sizeof(short_t) + > sizeof(size_type) - 1) / sizeof(size_type) : > (sizeof(long_t) + > sizeof(size_type) - 1) / sizeof(size_type); > > -- > Ben Combee <[EMAIL PROTECTED]> > CodeWarrior for Palm OS technical lead > Palm OS programming help @ www.palmoswerks.com > > >
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
