Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2020-12

Two versions of freemem() - are they equal

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marco van de Voort
to Graeme Geldenhuys

Op 2020-12-30 om 23:54 schreef Graeme Geldenhuys via fpc-pascal:

Show quoted text 6 lines
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, Delphi and FPC don't.  The overload with size is for TP compatibility.

Reply by email

Alexander Grotewohl
to Marco van de Voort

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 using freemem like above would be..

Alexander Grotewohl https://dcclost.com ________________________________
Earlier message 16 lines
From: fpc-pascal on behalf of Marco van de Voort via fpc-pascal Sent: Wednesday, December 30, 2020 5:56:45 PM To: FPC-Pascal users discussions Cc: Marco van de Voort Subject: Re: [fpc-pascal] Two versions of freemem() - are they equal 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, Delphi and FPC don't. The overload with size is for TP compatibility.

Reply by email