Deleting global references in JNI -
i not sure means:
virtual ~optimizer() { jnienv *env = getjnienv(); env->deleteglobalref(mjavaoptimizer); mjavaoptimizer = 0; }
what confuses me delete global reference , set 0. isn't deleting enough? why assignment 0 part?
thanks
in code, being in c++ destructor, has no practical use. it's programming pattern.
in many contexts, variable accessible (visible) before or after holds valid value. during times, preferable hold known value chosen value can tested (a sentinel value) and/or misuse reliably caught in defined way (e.g., null pointer vs bad pointer).
setting variable standard invalid value serves comment operation has invalidated previous value, might not obvious reading of immediate code.
Comments
Post a Comment