Recent

Author Topic: IMallocSpy.PreAlloc definition problem  (Read 286 times)

440bx

  • Hero Member
  • *****
  • Posts: 5593
IMallocSpy.PreAlloc definition problem
« on: July 03, 2025, 01:10:58 am »
Hello,

In activex.pp, IMallocSpy.PreAlloc is defined as follows:
Code: Pascal  [Select][+][-]
  1.         Function  PreAlloc(cbrequest:Size_t):Longint; StdCall;
  2.  
Note that the method's returned type is specified to be "Longint".

The C++ definition is:
Code: C  [Select][+][-]
  1.         virtual SIZE_T STDMETHODCALLTYPE PreAlloc(
  2.             /* [annotation][in] */
  3.             _In_  SIZE_T cbRequest) = 0;
  4.  
Note that the method's returned type is SIZE_T which is _not_ a Longint.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v4.0rc3) on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 17451
  • Ceterum censeo Trumpum esse delendum (Tnx Charlie)
Re: IMallocSpy.PreAlloc definition problem
« Reply #1 on: July 03, 2025, 07:28:29 am »
You should always be careful with definitions. I would add current, so the current C++ definition is...
That is because ms has changed the definitions over the past 30 years or so.
Not in a lot of places, but specifically COM is affected. Most of this is due to new compiler versions but some of them are because of enhanced portability. And the odd bugfix.
That does not mean that activex.pp should not be updated, it just means that activex.pp likely could have been correct at the time of writing.
You are right of course that the meaning of SIZE_T differs from longint, but in this case I think this is a change for portability.
« Last Edit: July 03, 2025, 07:31:31 am by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

 

TinyPortal © 2005-2018