In my experiance, using PChars is pretty dangerous, as a lot of systems
will show errors, and usually GetMem and FreeMem are the culprits. I
don't know the exact reason why, or what combinations of systems,
operating systems and API calls are the bad apples, but we have
thousands of users worldwide, and we just don't use Pchars at all.. its
not worth the hassle. We have gone to using array of Char, as long as
you know how many bytes to use. In fact some of my arrays are 6-7 k in
size, but the extra memory overhead is a lot better than the hassle of
whether it will work or not. With arrays it works, plain and simple.
Regards
Jason Coley
Manawatu Software Solutions
-----Original Message-----
From: Carl Reynolds [mailto:[EMAIL PROTECTED]]
Sent: Monday, 9 October 2000 1:21 p.m.
To: Multiple recipients of list delphi
Subject: RE: [DUG]: Creating PChars
On reflection my reply was misleading, or even downright wrong... :-}
StrAlloc and StrNew _in particular_ are in decline, because in the cases
where you want to have a few of bytes preceeding the string to hold
string
length information you're better off using an AnsiString - that's what
they
do best. So when you want to create a PChar explicitly, you'll almost
never
want the extra overhead of those four bytes of length information, and
consequently you should use GetMem/FreeMem.
Cheers,
Carl
>> From: Colin Fraser [mailto:[EMAIL PROTECTED]]
>> Is StrAlloc and StrDispose the way to go, or is GetMem and FreeMem
>> fine... or doesn't it matter???
>
> From: Carl Reynolds [mailto:[EMAIL PROTECTED]]
> I think the reason StrAlloc is marked as being in decline is just that
> explicit creation of PChars is in decline. That's because you can now
use
> pascal strings (string or AnsiString) in most cases, use SetLength,
and
pass
> PChar(MyString) as needed. But when you do need to create PChars,
either
> StrAlloc or GetMem will do.
------------------------------------------------------------------------
---
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"