RE: [Plib-devel] psl copy constructor.
Brought to you by:
sjbaker
From: Fay J. F C. AAC/W. <joh...@eg...> - 2004-04-19 15:07:19
|
Jonathan, I put your changes into my copy of PSL and it compiles nicely. The existing code around the changes mentions a need for reference counting and so it appears that what you have done is probably half the solution. Half is better than none, though, and I thank you for your contribution. The combination of your "is_copy" and the mentions of reference counting have gotten me thinking. Would it improve matters to declare "is_copy" to be a static integer (and probably rename it to something like "number_of_objects"), increment it in every constructor, decrement it in the destructor, and delete the compiler and code when its value is zero? I know nothing of PSL and really can't test this out at all. John F. Fay joh...@eg... -----Original Message----- From: pli...@li... [mailto:pli...@li...]On Behalf Of Jonathan Wheare Sent: Sunday, April 18, 2004 6:26 AM To: pli...@li... Subject: [Plib-devel] psl copy constructor. I've been tinkering with psl scripting and written myself a small manager class that will automatically create script instances using the copy constructor if there is already a compiled psl script in existance. this seems to work quite well until it is time to free the script instances. the first one works OK, but subsequent ones have problems. Looking through the code I found that there is no differentiation between instances and the scripts theey are created from when freeing the compiler and code structures. I've written a little bit of code that changes the pslProgram destructor so that it only frees the pslCode and pslCompiler objects on the master copy of a script. it will still cause problems if someone deletes the master copy of a script and continues to use instances created from it, but I can now create and delete ten instances of a script created using the copy constructor without problems. I have attatched a copy of my script at the end of this E-Mail. I would appreciate any feedback that people have. Thanks, Jonathan. <snip> |