Recent

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

440bx

  • Hero Member
  • *****
  • Posts: 6540
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.2.2 and Lazarus v4.0rc3 on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 19268
  • Glad to be alive.
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 »
objects are fine constructs. You can even initialize them with constructors.

 

TinyPortal © 2005-2018