[Lazarus] Help with basic pointer operations

Tommi Prami groups.tprami at gmail.com
Mon Aug 22 16:03:01 CEST 2011


Hello,

I kind of always try to stay away from the pointers, but now I maybe 
need to use them...

I think this is not correct yet (at least it does not to 100% what I like) :

var
   LSimpleStr     : string;
   LTmpWStr      : array [0..250] of WideChar;
...
   LSimpleStr := 'Some text';
   mwStrToWide(LSimpleStr, LTmpWStr ,  250);
...


procedure mwStrToWide(const AString: string; PWideString: PWideChar;
   const ABufferLen: Integer);
begin
   FillChar(PWideString^, ABufferLen, 0);

   if AString <>  '' then
   begin
     StringToWideChar(AString, PWideString, ABufferLen);
   end;
end;


With debugger it seems that the Buffer is not cleared correctly like I 
would like to (Much easier to debug when you see more easily the content 
of the Array).

And the most worrying part is that the code seems to work other vice, 
but I have the feeling that it is not 100% correct.

-TP-




More information about the Lazarus mailing list