File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -167,11 +167,23 @@ static void pypluginCache_free(cache_t* cache) {
167
167
return ;
168
168
}
169
169
170
- // Use smart pointer for automatic cleanup
171
- std::unique_ptr<pypluginCache_params_t, PypluginCacheParamsDeleter> params (
172
- static_cast <pypluginCache_params_t*>(cache->eviction_params ));
170
+ pypluginCache_params_t* params =
171
+ static_cast <pypluginCache_params_t*>(cache->eviction_params );
172
+
173
+ // Explicitly call the cache_free_hook before cleanup
174
+ if (!params->cache_free_hook .is_none ()) {
175
+ try {
176
+ params->cache_free_hook (params->data );
177
+ } catch (...) {
178
+ // Ignore exceptions during cleanup to prevent double-fault
179
+ }
180
+ }
181
+
182
+ // Clean up the parameters
183
+ delete params;
184
+ cache->eviction_params = nullptr ;
173
185
174
- // The smart pointer destructor will handle cleanup automatically
186
+ // Free the cache structure
175
187
cache_struct_free (cache);
176
188
}
177
189
You can’t perform that action at this time.
0 commit comments