Phil, This is a laudible plan, however fundamentally it won't remove the exit calls from plplot. The reason is that memory allocation can fail. We always need to check this and fail graceful, returning an error to the calling program and letting it decide how to procede. However we do the memory management, this is still true. The fundamental problem is that we have no mechanism for doing this at the moment since none of our functions return values. To change this is a massive API change. Another alternative would to have some global variable (like the errno variable used in the C library) and require calling programs to check this. This is not strictly an API change, but if we made it the default then it would be a big change in behaviour and would require user code changes to make the code safe. We could have it as an option though. More of a problem would be making sure this worked for all language bindings. A new function return the error flag would be one safe way.
Actually have a separate function which returns the error flag probably is a clean way of doing it. We can use the global variable internally as well for higher level function to check that lower level functions which may cause memory errors have exectuted without problems. I've thought about this a lot in the past and we've had threads on list and not come up with a good way of changing past design mistakes (or features?) in a painless way. Happy to be proved wrong of course and I'm not saying we shouldn't do something dramatic. We need to think it through careful though to make sure it is the right design decision and try to make it as simple as possible for users. In the meantime tidying up the code as you suggest will help minimise the places changes are required. Andrew On Mon, Sep 22, 2014 at 03:17:36PM +0100, Phil Rosenberg wrote: > This one is mostly directed at Alan but probably others will be interested > and may have comments. Git might also be a big help here, but I'm not sure > how it will work so advice from all appreciated. > > I have been trying to improve memory management in plplot as part of my > attempt to try to remove exit calls. To do this I am removing raw pointer > arrays and replacing them with a struct which will give us more object > oriented access to memory allocation. I think this will be a generally good > thing as the struct can have function pointers which will allow trivial > resizing and adding elements. It will also be extendible, to allow further > functionality similar to std::vector if we want. Arrays will also know their > own size. > > However the cost is that arrays in the plstream will all become structs so > will need accessing by somearray.mem[index] or maybe > somearray.getMem()[index] rather than somearray[index]. This has the > potential to break some or all the drivers. Although the fixes might be > trivial, I don't have easy access to all the drivers on my windows machine. > > I'm therefore looking for a suggestion of how to proceed. I can transfer > stuff to my Linux machine, but I'm not sure how best to do that with git. I > could create a fork on github so other developers can contribute, but if I > create a public fork then we should merge that into the master branch rather > than rebase it which I think is not compliant with our current workflow. > > Any suggestions greatly appreciated. > > Phil > ------------------------------------------------------------------------------ > Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer > Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports > Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper > Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer > http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk > _______________________________________________ > Plplot-devel mailing list > Plplot-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/plplot-devel ------------------------------------------------------------------------------ Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk _______________________________________________ Plplot-devel mailing list Plplot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/plplot-devel