Re: Danger of using FillMem() on a string? Speed of Abs()?
From: J French (erewhon_at_nowhere.com)
Date: 01/12/04
- Next message: Nicolai Hansen: "Re: Danger of using FillMem() on a string? Speed of Abs()?"
- Previous message: Maarten Wiltink: "Re: Two problems"
- In reply to: Jamie: "Re: Danger of using FillMem() on a string? Speed of Abs()?"
- Next in thread: Jamie: "Re: Danger of using FillMem() on a string? Speed of Abs()?"
- Reply: Jamie: "Re: Danger of using FillMem() on a string? Speed of Abs()?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 12 Jan 2004 12:32:32 +0000 (UTC)
On Sun, 11 Jan 2004 23:26:22 -0800, Jamie
<jamie_5_not_valid_after_5@charter.net> wrote:
>a string can be used ether way for API calls, the difference is that you
>need to set the desired length of the string before passing it as a
>PChar to a API function that is going to populate it and reset the
> length to its true value after the API call so that the end of string
>marker will line up on the NULL charactor.. this is only important if
>you plan on possibly adding to the string after the API call other wise
> it will add to the end of the SetLength that you set it for before the
>API call.
> for example ..
>Var
> S :String;
>Begin
> SetLength(S, Max_path);
> SetLength(S, GetWindowsDirectory(S, Pchar(Max_Path)));
Actually there is a major typo in the above
... PChar( MAX_PATH ) ???
Nitpicking ... but it is a good example how saving Variables can
obscure functionality - Terse code does not run faster
> ...
> this works well because the GetWindowsDirectory is called and resolved
> before the values are placed on the stack for the SetLength.
> etc.....
>
>
>
>
>>
>> ISTR somewhere in the Delphi help about casting between strings and
>> mchars, it basically says that you can cast a string to a PChar if and
>> only if you intend to use it as a read only variable (e.g. in the
>> context of a WinAPI call), and of course, it's not valid outside the
>> scope of the cast.
>>
>> MH.
>
- Next message: Nicolai Hansen: "Re: Danger of using FillMem() on a string? Speed of Abs()?"
- Previous message: Maarten Wiltink: "Re: Two problems"
- In reply to: Jamie: "Re: Danger of using FillMem() on a string? Speed of Abs()?"
- Next in thread: Jamie: "Re: Danger of using FillMem() on a string? Speed of Abs()?"
- Reply: Jamie: "Re: Danger of using FillMem() on a string? Speed of Abs()?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|