Re: Variants
- From: "Jim Mack" <jmack@xxxxxxxxxxxxxxx>
- Date: Tue, 22 Jul 2008 09:17:00 -0400
Lorin wrote:
So if I limit myself to Strings, User Defined Types and simple
types in a Variant is there a problem using the RTLMoveMemory?
For UDTs, arrays, objects etc (anything other than simple types), a
Variant always contains a pointer. Copying pointers blindly is a
recipe for crashes. VB doesn't expect that, so it doesn't accommodate
it.
Simple types, no problem. But strings in Variants are pointers, and I
can't see a scenario where it would be wise to use multiple copies of
a string pointer. By itself it's not an issue, but as soon as the
string goes out of scope or is otherwise destroyed via one pointer,
the other pointer becomes a time bomb.
If you're completely aware of the issues and vigilant about not
keeping dead pointers around or letting VB destroy them, maybe. But I
question how useful this would be, given the restrictions.
I have tried some memory operation on an array of variants holding
strings and an array of variants holding a user defined types and
it seems to work OK or am I just lucky and why?
You're just lucky -- so far. I can't say why. (-:
--
Jim
.
- Follow-Ups:
- Re: Variants
- From: Lorin
- Re: Variants
- References:
- Re: Variants
- From: Ralph
- Re: Variants
- Prev by Date: Re: Determine if file name is legal?
- Next by Date: Re: State machine implementation in vb tutorials?
- Previous by thread: Re: Variants
- Next by thread: Re: Variants
- Index(es):
Relevant Pages
|
Loading