[fpc-pascal] Two versions of freemem() - are they equal

2020-12-30 Thread Graeme Geldenhuys via fpc-pascal
Hi, Do both these method yield the same result, or is one better (performance, safer?) that the other? procedure FreeMem(p:pointer;Size:ptruint); procedure FreeMem(p:pointer); Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Re: [fpc-pascal] Two versions of freemem() - are they equal

2020-12-30 Thread Alexander Grotewohl via fpc-pascal
The TP7 manual suggests it was possible to partially free the memory. If you had a pointer to the un-freed chunk, I wonder if that could also have been freed, or if was left in limbo. As the manual suggests, I bet everyone just used SizeOf() as the parameter, and I'm not so sure how useful

Re: [fpc-pascal] GetClipboardFormatName causing an Error 216

2020-12-30 Thread Martin Frb via fpc-pascal
On 31/12/2020 01:09, James Richters via fpc-pascal wrote: Var FN : LPTSTR; Begin FN:=''; Writeln(Format_ID); GetClipboardFormatName(Format_Id,FN,250); Check the msdn help.

[fpc-pascal] GetClipboardFormatName causing an Error 216

2020-12-30 Thread James Richters via fpc-pascal
I'm trying to write a programs to get data from the windows clipboard that was put into it with Notepad++ using vertical editing. It uses a non-standard format and I'm trying to figure it out. GetClipboardFormatName is supposed to get me the name of non-standard formats, but whenever I try to run

Re: [fpc-pascal] GetClipboardFormatName causing an Error 216

2020-12-30 Thread Alexander Grotewohl via fpc-pascal
The memory for FN is allocated at the top with StrAlloc() -- Alexander Grotewohl https://dcclost.com From: fpc-pascal on behalf of Martin Frb via fpc-pascal Sent: Wednesday, December 30, 2020 8:00 PM To: fpc-pascal@lists.freepascal.org Cc: Martin Frb Subject:

Re: [fpc-pascal] GetClipboardFormatName causing an Error 216

2020-12-30 Thread Martin Frb via fpc-pascal
I missed you have FN:=StrAlloc (255); in that case see Alexanders response. On 31/12/2020 02:00, Martin Frb via fpc-pascal wrote: FN must point to an existing buffer (allocated mem) that receives the result. FN : Array [0..255]of Byte; GotLen := GetClipboardFormatName(Format_Id,

Re: [fpc-pascal] Two versions of freemem() - are they equal

2020-12-30 Thread Marco van de Voort via fpc-pascal
Op 2020-12-30 om 23:54 schreef Graeme Geldenhuys via fpc-pascal: Do both these method yield the same result, or is one better (performance, safer?) that the other? procedure FreeMem(p:pointer;Size:ptruint); procedure FreeMem(p:pointer); They are the same.   TP required size for deallocation,

Re: [fpc-pascal] GetClipboardFormatName causing an Error 216

2020-12-30 Thread Alexander Grotewohl via fpc-pascal
Your FN:=''; is clobbering the pointer 'FN' with nonsense. Just leave that line out, it isn't necessary. Or do like FN^:=#0; if you want C-string like functions to report zero length.. -- Alexander Grotewohl https://dcclost.com From: fpc-pascal on behalf of

Re: [fpc-pascal] GetClipboardFormatName causing an Error 216

2020-12-30 Thread Martin Frb via fpc-pascal
On 31/12/2020 01:09, James Richters via fpc-pascal wrote: I'm trying to write a programs to get data from the windows clipboard that was put into it with Notepad++ using vertical editing. Just for Info, SynEdit (trunk) can handle notepad++ column selection See the code at. There are 2 common