` Printed Icetips Article

Icetips Article



Clarion in general: Copying data from string to cstring without triggering non-thread safe RTL calls
2002-12-17 -- Andy Ireland
 
Newsgroups: comp.lang.clarion

> But "SomeStr = SomeCStr" ends up with a:
>
>   call dword [c55runx.dll:Cla$PushCString]  //Pushes a cstring onto the
> STRING stack
>   ...
>   call dword [c55runx.dll:Cla$PopCString]  //Pops a cstring from the STRING
> stack (converting it as it goes)
> For the type conversion...  Not safe!

Replace with....

MoveMemory(address(SomeStr), address(SomeCStr), len) where len is strlen
call from the VC++ RTL with null or not etc.

The problem is worse for num to string etc but itoa should be used in this
case. Also unsigned vars are processed using the stack therefore all values
are long and not ulong etc. You only need the correct number of bytes to
store it and not manipulate it as unsigned which accounts for 90% of usage
i.e pointers etc.

Regards

Andy
Plugware Solutions.com Ltd,  taking the puzzle out of I.T
Tel : +44 1249 813335
Fax : +44 1249 813462



Printed November 23, 2024, 3:29 am
This article has been viewed/printed 35224 times.
Google search has resulted in 321 hits on this article since January 25, 2004.