@@ -98,7 +98,7 @@ class ContextExt {
9898 private:
9999 uast::Context<NodeHandle> *ctx;
100100 jobject jCtxExt;
101-
101+
102102 jobject toJ (NodeHandle node) {
103103 if (node == 0 ) return nullptr ;
104104
@@ -161,7 +161,7 @@ class ContextExt {
161161 void setJavaContext (jobject ctx) {
162162 jCtxExt = getJNIEnv ()->NewWeakGlobalRef (ctx);
163163 }
164-
164+
165165 // Iterate returns iterator over an external UAST tree.
166166 // Borrows the reference.
167167 uast::Iterator<NodeHandle> *Iterate (jobject node, TreeOrder order) {
@@ -211,7 +211,7 @@ jobject filterUastIterExt(ContextExt *ctx, jobject jCtx, jstring jquery, JNIEnv
211211
212212 // new UastIterExt()
213213 jobject iter = NewJavaObject (env, CLS_ITER, METHOD_ITER_INIT, 0 , 0 , it, jCtx);
214-
214+
215215 if (env->ExceptionCheck () || !iter) {
216216 delete (it);
217217 checkJvmException (" failed create new UastIterExt class" );
@@ -377,14 +377,14 @@ class Node : public uast::Node<Node *> {
377377
378378 return s;
379379 }
380+ // Borrows the reference
380381 Node *ValueAt (size_t i) {
381382 if (!obj || i >= Size ()) return nullptr ;
382383
383384 JNIEnv *env = getJNIEnv ();
384385 jobject val =
385386 ObjectMethod (env, " valueAt" , METHOD_JNODE_VALUE_AT, CLS_JNODE, obj, i);
386- // TODO(#113) investigate, it looks like a potential memory leak
387- return lookupOrCreate (val); // borrows the reference
387+ return lookupOrCreate (val);
388388 }
389389
390390 void SetValue (size_t i, Node *val) {
@@ -429,7 +429,7 @@ struct EqualByObj {
429429};
430430
431431// Custom hasing function for keys in std::map<object>.
432- // Deligates actual hasing to the managed .hashCode() impl.
432+ // Delegates actual hasing to the managed .hashCode() impl.
433433struct HashByObj {
434434 std::size_t operator ()(jobject obj) const noexcept {
435435 auto hash = IntMethod (getJNIEnv (), " hashCode" , " ()I" , CLS_OBJ, obj);
@@ -451,15 +451,15 @@ class Interface : public uast::NodeCreator<Node *> {
451451
452452 if (obj2node.count (obj) > 0 ) {
453453 return obj2node[obj];
454- } else {
455- Node* node = new Node (this , obj);
456- obj2node[node->obj ] = node;
457- return node;
458454 }
455+
456+ Node *node = new Node (this , obj);
457+ obj2node[node->obj ] = node;
458+ return node;
459459 }
460460
461461 // create makes a new object with a specified kind.
462- // Steals the reference.
462+ // Creates new reference.
463463 Node *create (NodeKind kind, jobject obj) {
464464 Node *node = new Node (this , kind, obj);
465465 obj2node[node->obj ] = node;
@@ -610,7 +610,7 @@ class Context {
610610 // handle for the native context, called nativeContext
611611 jobject jCtxExt = ObjectField (env, src, " ctx" , FIELD_NODE_EXT_CTX);
612612 ContextExt *nodeExtCtx = getHandle<ContextExt>(env, jCtxExt, nativeContext);
613-
613+
614614 checkJvmException (" failed to get NodeExt.ctx" );
615615
616616 auto sctx = nodeExtCtx->ctx ;
@@ -652,7 +652,7 @@ JNIEXPORT jobject JNICALL Java_org_bblfsh_client_v2_libuast_Libuast_decode(
652652
653653 // Associates the JVM context ext to the native ContextExt
654654 p->setJavaContext (jCtxExt);
655-
655+
656656 if (env->ExceptionCheck () || !jCtxExt) {
657657 jCtxExt = nullptr ;
658658 // This also deletes the underlying ctx
@@ -682,12 +682,12 @@ Java_org_bblfsh_client_v2_libuast_Libuast_00024UastIter_nativeInit(
682682
683683 // global ref will be deleted by Interface destructor on ctx deletion
684684 auto it = ctx->Iterate (jnode, (TreeOrder)order);
685-
685+
686686 // this.iter = it;
687- setHandle<uast::Iterator<Node *>>(env, self, it, " iter" );
687+ setHandle<uast::Iterator<Node *>>(env, self, it, " iter" );
688688 // this.ctx = Context(ctx);
689689 setObjectField (env, self, jCtx, " ctx" , FIELD_ITER_CTX);
690-
690+
691691 return ;
692692}
693693
@@ -696,7 +696,7 @@ Java_org_bblfsh_client_v2_libuast_Libuast_00024UastIter_nativeDispose(
696696 JNIEnv *env, jobject self) {
697697 // this.ctx will be disposed by Context finalizer
698698 setObjectField (env, self, nullptr , " ctx" , FIELD_ITER_CTX);
699-
699+
700700 // this.iter
701701 auto iter = getHandle<uast::Iterator<Node *>>(env, self, " iter" );
702702 setHandle<uast::Iterator<Node *>>(env, self, 0 , " iter" );
@@ -729,20 +729,20 @@ Java_org_bblfsh_client_v2_libuast_Libuast_00024UastIter_nativeNext(
729729JNIEXPORT void JNICALL
730730Java_org_bblfsh_client_v2_libuast_Libuast_00024UastIterExt_nativeInit (
731731 JNIEnv *env, jobject self) { // sets iter and ctx, given node: NodeExt
732-
732+
733733 jobject nodeExt = ObjectField (env, self, " node" , FIELD_ITER_EXT_NODE);
734734 if (!nodeExt) {
735735 return ;
736736 }
737-
737+
738738 jobject jCtxExt = ObjectField (env, nodeExt, " ctx" , FIELD_NODE_EXT_CTX);
739739
740740 if (!jCtxExt)
741741 return ;
742742
743743 // borrow ContextExt from NodeExt
744744 ContextExt *ctx = getHandle<ContextExt>(env, jCtxExt, nativeContext);
745-
745+
746746 jint order = IntField (env, self, " treeOrder" , " I" );
747747 if (order < 0 ) {
748748 return ;
@@ -754,7 +754,7 @@ Java_org_bblfsh_client_v2_libuast_Libuast_00024UastIterExt_nativeInit(
754754 setHandle<uast::Iterator<NodeHandle>>(env, self, it, " iter" );
755755 // this.ctx = jCtxExt;
756756 setObjectField (env, self, jCtxExt, " ctx" , FIELD_ITER_EXT_CTX);
757-
757+
758758 return ;
759759}
760760
@@ -763,7 +763,7 @@ Java_org_bblfsh_client_v2_libuast_Libuast_00024UastIterExt_nativeDispose(
763763 JNIEnv *env, jobject self) {
764764 // this.ctx will be disposed by ContextExt finalizer
765765 setObjectField (env, self, nullptr , " ctx" , FIELD_ITER_EXT_CTX);
766-
766+
767767 // this.iter
768768 auto iter = getHandle<uast::Iterator<NodeHandle>>(env, self, " iter" );
769769 setHandle<uast::Iterator<NodeHandle>>(env, self, 0 , " iter" );
@@ -841,7 +841,7 @@ Java_org_bblfsh_client_v2_Context_00024_create(JNIEnv *env, jobject self) {
841841JNIEXPORT void JNICALL Java_org_bblfsh_client_v2_Context_dispose (JNIEnv *env,
842842 jobject self) {
843843 Context *p = getHandle<Context>(env, self, nativeContext);
844-
844+
845845 if (p) {
846846 delete p;
847847 setHandle<Context>(env, self, 0 , nativeContext);
0 commit comments