It's no big deal. I normally don't use SWAP on that type of data because
of the old description in the docs. I usually code the functions that handle
that type of data in inline assembler.
It works in PB/DLL6 so I will not pursue the matter any further.
------------------
Dominic Mitchell
Announcement
Collapse
No announcement yet.
SWAP and GlobalAlloc/HeapAlloc
Collapse
X
-
Dominic, if you can show us a full example, we can look into it for you.
Or send it to mailto:[email protected][email protected]</A> .
Semen, SWAP is not necessarily the fastest technique for items involving
just a few bytes. It probably uses something like a REP MOVSx in many
cases, which imposes a bit of start-up overhead. This is not likely
to be an issue unless you need to swap an awful lot of very small items
very quickly.
------------------
Tom Hanlin
PowerBASIC Staff
Leave a comment:
-
Eric --
we are both do not use exact termins.
Dynamic strings - I can agree w/o test, because PB compile is enough clever.
Fixed-length strings / Asciiz - I am not ready to agree (at least, w/o test)
------------------
E-MAIL: [email protected]
Leave a comment:
-
> SWAP is not fast operation. Allocates temporary string
No, when used with strings SWAP swaps the string pointers/handles, not the string data. It's very fast!
-- Eric
------------------
Perfect Sync Development Tools
Perfect Sync Web Site
Contact Us: mailto:[email protected][email protected]</A>
Leave a comment:
-
Dominic --
works (but as I remember, SWAP is not fast operation. Allocates temporary string ?)
------------------
E-MAIL: [email protected]
Leave a comment:
-
SWAP and GlobalAlloc/HeapAlloc
Code:TYPE KEYWORDEX ' kwdx cbName AS BYTE ' Count of bytes in keyword name bType AS BYTE ' Type of keyword szName AS ASCIIZ * 64 ' Keyword name END TYPE
using GlobalAlloc.
<256*4-bytes jump table><256*4-bytes count table><keyword count * SIZEOF(KEYWORDEX)>
LOCAL ptkwdx AS KEYWORDEX PTR
lpTbl = GlobalAlloc(%GMEM_FIXED OR %GMEM_ZEROINIT, 2048 + 2000 * SIZEOF(tkwdx))
ptkwdx = lpTbl + 2048
The errata on SWAP says that it can be used to swap the target values of pointers
and that this applies to PB/DLL 6.0 & PB/CC 2.0. However, the following produces
bad data on PB/DLL 5.0.
SWAP @ptkwd[1].szName, @ptkwd[3].szName
Just wondering if this was fixed in version 6.
------------------
Dominic MitchellTags: None
Leave a comment: