diff options
-rw-r--r-- | m4/ax_cxx_gcc_abi_demangle.m4 | 2 | ||||
-rw-r--r-- | src/cppunit/TypeInfoHelper.cpp | 14 |
2 files changed, 12 insertions, 4 deletions
diff --git a/m4/ax_cxx_gcc_abi_demangle.m4 b/m4/ax_cxx_gcc_abi_demangle.m4 index 0275c7e..3f1876b 100644 --- a/m4/ax_cxx_gcc_abi_demangle.m4 +++ b/m4/ax_cxx_gcc_abi_demangle.m4 @@ -32,7 +32,7 @@ ax_cv_cxx_gcc_abi_demangle, AC_LANG_CPLUSPLUS AC_TRY_COMPILE([#include <typeinfo> #include <cxxabi.h> -#include <malloc.h> +#include <cstdlib> #include <string> template<typename TYPE> diff --git a/src/cppunit/TypeInfoHelper.cpp b/src/cppunit/TypeInfoHelper.cpp index ff1d662..2df5786 100644 --- a/src/cppunit/TypeInfoHelper.cpp +++ b/src/cppunit/TypeInfoHelper.cpp @@ -6,7 +6,7 @@ #include <string> #if CPPUNIT_HAVE_GCC_ABI_DEMANGLE -#include <malloc.h> +#include <cstdlib> #include <cxxabi.h> #endif @@ -24,8 +24,16 @@ TypeInfoHelper::getClassName( const std::type_info &info ) c_name = abi::__cxa_demangle( info.name(), 0, 0, &status ); - std::string name( c_name ); - free( c_name ); + std::string name; + if(c_name) + { + name = std::string( c_name ); + free( c_name ); + } + else + { + name = std::string( info.name() ); + } #else // CPPUNIT_HAVE_GCC_ABI_DEMANGLE |