If you want it as a callback it needs to be a class function and static; And the proper calling convention added: cdecl or winapi/stdcall;
Or you should unhide the hidden self parameter in a function prototype.
// no of object, but exposed self. You can assign an object method to it. (w/o the self exposed)
TEnsureDataCallback=function(_self:pointer;const DataPtr: Pointer; MaxLen: Integer): Integer;stdcall;
//or:
type
TEnsureDataCallback=function(const DataPtr: Pointer; MaxLen: Integer): Integer;stdcall;
TMytype = record
public
class function EnsureDataCallBack(const DataPtr: Pointer; MaxLen: Integer): Integer;stdcall;static; // Now it's assignable
end;
The choice depends on what you want to achieve. Interoperability with C code,maybe? Or your own Pascal code?