diff --git a/alib2common/src/cast/CastApi.hpp b/alib2common/src/cast/CastApi.hpp index a0750734db2eb277c288f5ddd7eb38ccac9b85e9..dbb1d1318e375bc7225a86cbd24fd7ce4896d52c 100644 --- a/alib2common/src/cast/CastApi.hpp +++ b/alib2common/src/cast/CastApi.hpp @@ -34,9 +34,7 @@ struct castApi { std::map < std::type_index, std::function < alib::Object ( const alib::ObjectBase & ) > >::iterator res = castFunctions.find ( std::type_index ( typeid ( from ) ) ); if ( res == castFunctions.end ( ) ) { - char* name = std::type_name(typeid(from)); - std::string fromType(name); - std::free(name); + std::string fromType = std::cstringToString(std::type_name(typeid(from))); throw exception::CommonException ( "Bad cast: From: " + fromType + " To: " + toType()); } @@ -72,9 +70,7 @@ struct castApi { } std::string toType ( ) { - char* name = std::type_name<To>(); - std::string toType(name); - std::free(name); + std::string toType = std::cstringToString(std::type_name<To>()); return toType; } @@ -131,9 +127,7 @@ public: std::map < std::type_index, CastPoolBase * >::iterator res = castFunctionsById ( ).find ( typeId ); if ( res == castFunctionsById ( ).end ( ) ) { - char* name = std::type_name( typeId ); - std::string toType(name); - std::free(name); + std::string toType = std::cstringToString(std::type_name( typeId )); throw exception::CommonException ( "Casting to type " + toType + " not available." ); } else