@Markov: Why don't change it or at least overload it? It doesn't seem complicated
I know that getmen wraps sysgetmen and getmen by itself is direct call to this procedure. I point to the interface that i cannot change and seems possible to change safely without trouble.
I suppose that when new (p) is in compiler time and is traslated in some call to the direction pointer by getmen in compiler time, because it knows size of (p). So this is made by compiler and not delphi or tp or dialect, so the entry point can be changed without issues. This is a construct like write made by compiler. So new (p) should call the procedural way internally to get the programmer the tool of know (p) as in dispose way.
So let's go for the other ways. That some existent memory manager (not default) exists and we know to maintain their way. Then the procedural way should be filled by default with some kind code calling the old function. But being the procedural way the entry point for the Compiler...
procedure getmen (var localpointer:pointer; size:ptrint);
begin
localpointer:=getmen (size) // the old sysmanager is called correctly
end
This should maintain the old function way, but at least give the programmer a way to see (p). In class constructors, it should be compiled or transformed to point the procedural way.
I think it's logical that the variable in which should be stored the pointer be visible. I do not know why this is not to change. It can be implemented as extension and trasparently by compiler.
Example of extended TManager respecting old ways. (@Taddy i used your idea in different way

)
TMemoryManager = record
NeedLock : Boolean;
Getmem : Function(Size:PtrInt):Pointer; /// i prefer procedural way
Freemem : Function(var p:pointer):PtrInt;
FreememSize : Function(var p:pointer;Size:PtrInt):PtrInt;
AllocMem : Function(Size:PtrInt):Pointer;
ReAllocMem : Function(var p:pointer;Size:PtrInt):Pointer;
MemSize : function(p:pointer):PtrInt;
InitThread : procedure;
DoneThread : procedure;
RelocateHeap : procedure;
GetHeapStatus : function :THeapStatus;
GetFPCHeapStatus : function :TFPCHeapStatus;
Getmem: procedure(out p:pointer;Size:PtrInt); /// ADD this record field
Getmem : Function(const p: pointer;Size:PtrInt):Pointer; /// other way
end;
Even it could be even more ways for example extending in the interface and passing allways the p as an internal parameter. Or this p being in some accesible place.
Or if we go creative, even tricky ways and compiler extensions: if a function has Result, a @callerResult could be a point to the adress of variable storing the value of the function -> this languaje construct will make any function call know as extraparameter the storing variable, but i only will allow this with some kind of extended compiler flag like const var changing. But i go for the simple way: Changing the entry point and having pointer as parameter.
And as you know, p is pointing to data, but p-8 and p-16 is pointing to pointermetadata (like size), so knowing p, one can know if it is a valid pointer and What kind/class of smartpointer could be).
So Why not is going to change? Where are the compatibility issues? I think the memory management is in a layer previous (how is compiled new and the constructors solver like write (p1,p2,p3...) ), so it can be solved in compile time and not being a language issue.
I think the only "big" think is to change the entry point from the function to the procedural way in compiler time (which i think is were it's done). For compatibility filling it with a call to the function way for old code, and new power for the memory managers with the new code.
Even it shouldn't be a performance issue. If compiler is smart enought this code could be removed by compiler optimization call a that calls b that calls c compiled by call to c from a...
@Taddy: Not need to extend the record as you say. Actually i can call with the function my own getmem. The issue is the "entry point". It's the reverse. Calling the function with the entry point in procedural getmen (or any two parameters getmen with the p and the size) saving the knowledge of the pointer content. But it's good idea to extend the record to use the new capabilities saving the old ways

PD: Sorry for my bad english. I'm not english native
