Re: [fpc-pascal] Converting StrLCopy to widestrings

2007-11-18 Thread Felipe Monteiro de Carvalho
On Nov 18, 2007 2:11 PM, Marc Weustink <[EMAIL PROTECTED]> wrote: > I need to review the code in that area, imo it is not needed. I couldn't make it work without allocating. There is no permanent storage for the data available. > anyway when is the allocateed memory freed ? I noticed that it's n

Re: [fpc-pascal] Converting StrLCopy to widestrings

2007-11-18 Thread Marc Weustink
Felipe Monteiro de Carvalho wrote: On Nov 17, 2007 1:25 PM, Marc Weustink <[EMAIL PROTECTED]> wrote: First question, why is the copying needed ? Why isn'tlpStrFile := PWChar(FileNameWide); simply enough ? IMO, you're copying way to much. That variable is only valid on the scope of the fun

Re: [fpc-pascal] Converting StrLCopy to widestrings

2007-11-17 Thread Felipe Monteiro de Carvalho
On Nov 17, 2007 1:25 PM, Marc Weustink <[EMAIL PROTECTED]> wrote: > First question, why is the copying needed ? > Why isn'tlpStrFile := PWChar(FileNameWide); > simply enough ? > > IMO, you're copying way to much. That variable is only valid on the scope of the function, and we need something m

Re: [fpc-pascal] Converting StrLCopy to widestrings

2007-11-17 Thread Marc Weustink
Felipe Monteiro de Carvalho wrote: Hello, In a LCL code we have: var FileNameBuffer: PChar; FileNameWide: WideString; FileNameWideBuffer: PWideChar; FilterBuffer: WideString; begin {$ifdef WindowsUnicodeSupport} if UnicodeEnabledOS then FileNameWideBuffer := AllocMem(FileNameBuffe

[fpc-pascal] Converting StrLCopy to widestrings

2007-11-17 Thread Felipe Monteiro de Carvalho
Hello, In a LCL code we have: var FileNameBuffer: PChar; FileNameWide: WideString; FileNameWideBuffer: PWideChar; FilterBuffer: WideString; begin {$ifdef WindowsUnicodeSupport} if UnicodeEnabledOS then FileNameWideBuffer := AllocMem(FileNameBufferLen * 2 + 2) else FileNameBuff