<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Hairy Pixels via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>> schrieb am Sa., 19. Okt. 2024, 15:14:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Oct 19, 2024 at 8:10:02 PM, Sven Barth via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank" rel="noreferrer">fpc-pascal@lists.freepascal.org</a>> wrote:<br></div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" type="cite">
For a class one can override NewInstance and FreeInstance. And with TVirtualMethodInterceptor (I think not yet implemented in FPC) it might even be possible to replace these on an existing class type without inheriting from it. I have not tested that yet, but it *might* work. <br>
</blockquote>
</div>
<br>
<div dir="ltr">This isn’t good enough though. The idea is you have multiple allocators for different life times in your program and allocate each class from one of those. A type based allocator is global for all classes and while you can push/pop allocators in scopes this isn’t thread safe.</div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">You didn't understand what I wrote. Assuming what I thought up works, it would be possible to replace NewInstance and FreeInstance *per instance* as desired. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>