mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Remove external destroy method
OpenMC will call delete directly on the CustomSource.
This commit is contained in:
parent
651c8825f3
commit
fae474869c
4 changed files with 3 additions and 19 deletions
|
|
@ -65,10 +65,3 @@ class ParameterizedSource : public openmc::CustomSource {
|
|||
extern "C" ParameterizedSource* create(const char* parameters) {
|
||||
return ParameterizedSource::from_string(parameters);
|
||||
}
|
||||
|
||||
// A function to destroy a pointer to an instance of this class when generated
|
||||
// via a plugin call using dlopen/dlsym.
|
||||
// You must have external C linkage here otherwise dlopen will not find the file
|
||||
extern "C" void destroy(ParameterizedSource* source) {
|
||||
delete source;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,6 @@ class CustomSource {
|
|||
};
|
||||
|
||||
typedef CustomSource* create_custom_source_t(const char* parameters);
|
||||
typedef void destroy_custom_source_t(CustomSource*);
|
||||
|
||||
//==============================================================================
|
||||
// Functions
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ sample_t custom_source_function;
|
|||
|
||||
std::string custom_source_parameters;
|
||||
CustomSource* custom_source;
|
||||
destroy_custom_source_t* destroy_custom_source;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -380,9 +379,8 @@ void load_custom_source_library()
|
|||
using sample_t = Particle::Bank (*)(uint64_t* seed);
|
||||
custom_source_function = reinterpret_cast<sample_t>(dlsym(custom_source_library, "sample_source"));
|
||||
} else {
|
||||
// get the functions to create and destroy the CustomSource from the library
|
||||
// get the function to create the CustomSource from the library
|
||||
create_custom_source_t* create_custom_source = (create_custom_source_t*) dlsym(custom_source_library, "create");
|
||||
destroy_custom_source = (destroy_custom_source_t*) dlsym(custom_source_library, "destroy");
|
||||
|
||||
// create a pointer to an instance of the CustomSource
|
||||
custom_source = create_custom_source(custom_source_parameters.c_str());
|
||||
|
|
@ -404,8 +402,8 @@ void load_custom_source_library()
|
|||
void close_custom_source_library()
|
||||
{
|
||||
if (custom_source) {
|
||||
// destroy the CustomSource if it exists
|
||||
destroy_custom_source(custom_source);
|
||||
// delete the CustomSource if it exists
|
||||
delete custom_source;
|
||||
}
|
||||
|
||||
#ifdef HAS_DYNAMIC_LINKING
|
||||
|
|
|
|||
|
|
@ -58,9 +58,3 @@ class ParameterizedSource : public openmc::CustomSource {
|
|||
extern "C" ParameterizedSource* create(const char* parameters) {
|
||||
return ParameterizedSource::from_string(parameters);
|
||||
}
|
||||
|
||||
// you must have external C linkage here otherwise
|
||||
// dlopen will not find the file
|
||||
extern "C" void destroy(ParameterizedSource* source) {
|
||||
delete source;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue