wdas / SeExpr

SeExpr is an embeddable, arithmetic expression language that enables flexible artistic control and customization in creating computer graphics images. Example uses include procedural geometry synthesis, image synthesis, simulation control, crowd animation, and geometry deformation. https://wdas.github.io/SeExpr
https://www.disneyanimation.com/open-source/seexpr/
Other
405 stars 86 forks source link

fixed function user data leak #76

Closed ix-dcourtois closed 7 years ago

ix-dcourtois commented 7 years ago

Here is a proposition to fix user data leaks when returning new data in a ExprFuncSimple::evalConstant call.

ix-dcourtois commented 7 years ago

Ok, sorry for the multiple commits, I should have tested a bit more before commiting. The last commit (172376f) should do the trick.

Basically I added a boolean member to SeExpr::ExprFuncNode::Data which is initialized to false by deafult (to keep the current behavior of SeExpr) When the node is destroyed, it checked if it has some data, and if so, will destroy it if that member is true.

This way users can flag their function's data to be automatically cleaned up, or left as it is (if they returned a pointer to a static/global or are managing their destruction themselves)

jberlin commented 7 years ago

Makes sense -- thanks!