Could you tell me what is the standard object-oriented way to re-design a pointer-based memory allocation solution so as not to have to calculate explicitly how much memory is required for a given data type but that a memory manager determines whether the allocation is possible at a given run-time?
Any memory manager should already do that. The memory manager always needs to know how much memory you need, and it should always know how much is available, so determining whether a request is possible should be very easy by simply comparing the two values.
When you instantiate an object, note that you as a programmer never indicate exactly how much memory you need. Instead, the compiler provides that information to the memory manager for you. Every class has a method, InstanceSize, that the class's constructor calls to figure out how much memory to allocate. (There are some nasty tricks you can use to have an object allocate more memory than the compiler originally requested.)
Unless you're somehow defining types at run time, the memory manager has no need to "calculate" how much memory a type will need. Instead, the type already knows its size (because the compiler calculated it when the type was defined), and so any calls into the memory manager can include that size already.
If this problem sounds just shy of tracktable as stated, I can provide source code fragment.
Please do.
-- Rob
_______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

