diff --git a/include/eepp/core/memorymanager.hpp b/include/eepp/core/memorymanager.hpp index a977e60a1..39c18d1d4 100644 --- a/include/eepp/core/memorymanager.hpp +++ b/include/eepp/core/memorymanager.hpp @@ -26,8 +26,11 @@ class EE_API AllocatedPointer { typedef std::map AllocatedPointerMap; typedef AllocatedPointerMap::iterator AllocatedPointerMapIt; + +#if defined( __GNUC__ ) && __GNUC__ >= 12 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wuse-after-free" +#endif class EE_API MemoryManager { public: static void* addPointer( const AllocatedPointer& aAllocatedPointer ); @@ -65,7 +68,9 @@ class EE_API MemoryManager { static const AllocatedPointer& getBiggestAllocation(); }; +#if defined( __GNUC__ ) && __GNUC__ >= 12 #pragma GCC diagnostic pop +#endif #ifdef EE_MEMORY_MANAGER #define eeNewTracked( classType, constructor ) \ @@ -88,41 +93,53 @@ class EE_API MemoryManager { #define eeMalloc( amount ) \ EE::MemoryManager::addPointer( EE::AllocatedPointer( EE::MemoryManager::allocate( amount ), \ __FILE__, __LINE__, amount ) ) + +#if defined( __GNUC__ ) && __GNUC__ >= 12 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wuse-after-free" +#endif #define eeRealloc( ptr, amount ) \ EE::MemoryManager::reallocPointer( \ ptr, EE::AllocatedPointer( EE::MemoryManager::reallocate( ptr, amount ), __FILE__, \ __LINE__, amount ) ) +#if defined( __GNUC__ ) && __GNUC__ >= 12 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wuse-after-free" +#endif #define eeDelete( data ) \ { \ if ( EE::MemoryManager::removePointer( EE::MemoryManager::deletePtr( data ), __FILE__, \ __LINE__ ) == false ) \ printf( "Deleting at '%s' %d\n", __FILE__, __LINE__ ); \ } +#if defined( __GNUC__ ) && __GNUC__ >= 12 #pragma GCC diagnostic pop #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wuse-after-free" +#endif + #define eeDeleteArray( data ) \ { \ if ( EE::MemoryManager::removePointer( EE::MemoryManager::deleteArrayPtr( data ), \ __FILE__, __LINE__ ) == false ) \ printf( "Deleting at '%s' %d\n", __FILE__, __LINE__ ); \ } +#if defined( __GNUC__ ) && __GNUC__ >= 12 #pragma GCC diagnostic pop #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wuse-after-free" +#endif #define eeFree( data ) \ { \ if ( EE::MemoryManager::removePointer( EE::MemoryManager::free( data ), __FILE__, \ __LINE__ ) == false ) \ printf( "Deleting at '%s' %d\n", __FILE__, __LINE__ ); \ } +#if defined( __GNUC__ ) && __GNUC__ >= 12 #pragma GCC diagnostic pop +#endif #else diff --git a/src/eepp/system/sys.cpp b/src/eepp/system/sys.cpp index 0b7974187..a653cd7f3 100644 --- a/src/eepp/system/sys.cpp +++ b/src/eepp/system/sys.cpp @@ -40,6 +40,7 @@ #if EE_PLATFORM == EE_PLATFORM_MACOSX || EE_PLATFORM == EE_PLATFORM_BSD || \ EE_PLATFORM == EE_PLATFORM_IOS +#include #include #endif @@ -951,6 +952,23 @@ std::vector Sys::getLogicalDrives() { } endmntent( file ); return ret; +#elif EE_PLATFORM == EE_PLATFORM_MACOSX || EE_PLATFORM == EE_PLATFORM_BSD || \ + EE_PLATFORM == EE_PLATFORM_IOS + std::vector ret; + struct statfs* mounts; + int numMounts = getmntinfo( &mounts, MNT_NOWAIT ); + if ( numMounts <= 0 ) + return ret; + for ( int i = 0; i < numMounts; ++i ) { + auto mnt = mounts[i]; + std::string mntType( mnt.f_mntfromname ); + + if ( mntType == "devfs" || mntType == "autofs" ) + continue; + + ret.emplace_back( mnt.f_mntonname ); + } + return ret; #else return {}; #endif