@@ -110,6 +110,8 @@ static bool njsDbObjectType_populateTypeInfo(njsDataTypeInfo *info,
110
110
njsBaton * baton , napi_env env , dpiDataTypeInfo * sourceInfo );
111
111
static bool njsDbObject_wrap (napi_env env , napi_value value ,
112
112
njsDbObject * * obj );
113
+ static napi_value njsDbObjectType_refCleanup (napi_env env ,
114
+ napi_callback_info info );
113
115
114
116
115
117
//-----------------------------------------------------------------------------
@@ -188,6 +190,7 @@ static void njsDbObject_finalize(napi_env env, void *finalizeData,
188
190
dpiObject_release (obj -> handle );
189
191
obj -> handle = NULL ;
190
192
}
193
+ obj -> type = NULL ;
191
194
free (obj );
192
195
}
193
196
@@ -877,6 +880,21 @@ static void njsDbObjectType_finalize(napi_env env, void *finalizeData,
877
880
free (type );
878
881
}
879
882
883
+ //-----------------------------------------------------------------------------
884
+ // njsDbObjectType_refCleanup()
885
+ // Invoked when njsDbObjectType reference count needs to be decremented.
886
+ // This is required for the clean up of obj type reference created
887
+ // in njsDbObjectType_populate.
888
+ //-----------------------------------------------------------------------------
889
+ static napi_value njsDbObjectType_refCleanup (napi_env env ,
890
+ napi_callback_info info )
891
+ {
892
+ njsDbObjectType * type ;
893
+
894
+ napi_get_cb_info (env , info , NULL , NULL , NULL , (void * * ) & type );
895
+ NJS_DELETE_REF_AND_CLEAR (type -> jsDbObjectType );
896
+ return NULL ;
897
+ }
880
898
881
899
//-----------------------------------------------------------------------------
882
900
// njsDbObjectType_populate()
@@ -995,6 +1013,11 @@ static bool njsDbObjectType_populate(njsDbObjectType *objType,
995
1013
NJS_CHECK_NAPI (env , napi_set_named_property (env , jsObjectType ,
996
1014
"isCollection" , temp ))
997
1015
1016
+ // cleanup function
1017
+ NJS_CHECK_NAPI (env , napi_create_function (env , "refCleanup" , NAPI_AUTO_LENGTH ,
1018
+ njsDbObjectType_refCleanup , objType , & temp ))
1019
+ NJS_CHECK_NAPI (env , napi_set_named_property (env , jsObjectType , "refCleanup" ,
1020
+ temp ))
998
1021
return true;
999
1022
}
1000
1023
0 commit comments