Dave Sellers wrote: > Thanks for that and yes, it is very different! > > For me, Walter's solution has one big advantage: I can understand it..... > > This is no criticism (cos I don't even understand how this works!)
Well, I didn't fully understand it until a few hours ago. What I posted was a rewrite of what I originally had since my previous code would either be a security threat (setting memory to be executable that really shouldn't be) or a big waste of memory (allocating 4 KB per method when all I need is a dozen bytes). It's now based on what Delphi uses for patching methods into window procedures in the VCL. > but isn't it a mighty complicated solution? In terms of figuring out where all those pointers really point, yes. I had to make a few diagrams. I never would have thought of that code on my own. > Are there advantages to it over Walter's? My code will work with whatever TList you have. You can create sorting callbacks for use with TList, TObjectList, TClassList, TComponentList, TThreadList, and whatever else you find that expects a TListSortCompare function pointer. Walter's, on the other hand, is specific to TObjectList. If you wanted to sort a TList with a method pointer, you'd need to make a TList descendant that had the same special Sort replacement as is already in TObjectListEx. Likewise for TComponentList and TClassList. We can't add that capability to _all_ of TList's descendants without modifying TList itself. A similarity: Walter and I both copied most of our code straight from Classes.pas. > What is the significance of 313 for the InstanceCount constant? Ask Borland. :) I suspect it's the maximum number of TSortInstance records that can go in the TInstanceBlock.Instances array and still fit within 4096 bytes, which is how much memory gets allocated (with VirtualAlloc) for each block. The code could calculate the size at run time (since the page size isn't guaranteed to be 4096 anyway) and get rid of those magic numbers. Maybe tomorrow. -- Rob ----------------------------------------------------- Home page: http://groups.yahoo.com/group/delphi-en/ To unsubscribe: [EMAIL PROTECTED] Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/delphi-en/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

