Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » WString0::Free() crashing
WString0::Free() crashing [message #40668] Thu, 29 August 2013 22:32 Go to next message
crydev is currently offline  crydev
Messages: 151
Registered: October 2012
Location: Netherlands
Experienced Member
Hello,

I am experiencing a crash that I cannot identify. When assigning a new wchar buffer to a WString class, I sometimes experience erors. Sometimes this does not occur, but sometimes it does. The crash it at:

inline int  AtomicDec(volatile Atomic& t)             { return InterlockedDecrement((Atomic *)&t); }


The calling code is:

WString* localValues; // just to show what type the array is, this is fully initialized so no problems here.
const wchar* strPtr = (const wchar*)&(buffer[i]);
localValues[arrayIndex++] = WString(strPtr, value.GetLength()); // value.GetLength() is the length of the string, say 5.


The usual String class does not produce errors, while the assignment method is exactly the same. Why does it crash? I am using Win32 ofcourse.

Thanks, crydev

[Updated on: Thu, 29 August 2013 22:33]

Report message to a moderator

Re: WString0::Free() crashing [message #40669 is a reply to message #40668] Thu, 29 August 2013 23:53 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 590
Registered: December 2005
Location: Budapest, Hungary
Contributor
You should create that WString objects on heap (with new) instead of stack, I think.
But the code would be much cleaner, using some container. U++ containers are very fast.
Re: WString0::Free() crashing [message #40677 is a reply to message #40669] Fri, 30 August 2013 22:21 Go to previous message
crydev is currently offline  crydev
Messages: 151
Registered: October 2012
Location: Netherlands
Experienced Member
I fixed it by changing the array to a Vector<WString> and using Vector.SetCount to gradually increase alloc to keep the size equal to my other arrays.

Thanks for the pointers!
Previous Topic: [BUG & Patch] Printing under POSIX dosen't work.
Next Topic: [BUG & Patch] TopWindow::CenterRect under X11 may lead to crash!!!
Goto Forum:
  


Current Time: Thu Nov 21 06:39:33 CET 2019

Total time taken to generate the page: 0.01493 seconds