Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid deleting incomplete type #4095

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/shogun/base/class_list.cpp.templ
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,8 @@ CSGObject* shogun::create(const char* classname, EPrimitiveType generic)

return NULL;
}

void shogun::delete_object(CSGObject* object)
{
delete object;
}
7 changes: 6 additions & 1 deletion src/shogun/base/class_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ namespace shogun {
*/
CSGObject* create(const char* sgserializable_name, EPrimitiveType generic);

/** deletes object
* @param object pointer to object to be deleted
*/
void delete_object(CSGObject* object);

/** Creates new shogun instance, typed.
*
* Throws an exception in case there is no such classname or
Expand All @@ -43,7 +48,7 @@ namespace shogun {
auto* cast = dynamic_cast<T*>(object);
if (!cast)
{
delete object;
delete_object(object);
SG_SERROR("Type mismatch");
}
cast->ref();
Expand Down