mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-27 16:38:20 +03:00
Fixed warnings with clang.
Implemented Sys::getLogicalDrives for macOS, BSD and iOS.
This commit is contained in:
@@ -26,8 +26,11 @@ class EE_API AllocatedPointer {
|
||||
typedef std::map<void*, AllocatedPointer> 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
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_MACOSX || EE_PLATFORM == EE_PLATFORM_BSD || \
|
||||
EE_PLATFORM == EE_PLATFORM_IOS
|
||||
#include <sys/mount.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
@@ -951,6 +952,23 @@ std::vector<std::string> Sys::getLogicalDrives() {
|
||||
}
|
||||
endmntent( file );
|
||||
return ret;
|
||||
#elif EE_PLATFORM == EE_PLATFORM_MACOSX || EE_PLATFORM == EE_PLATFORM_BSD || \
|
||||
EE_PLATFORM == EE_PLATFORM_IOS
|
||||
std::vector<std::string> 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
|
||||
|
||||
Reference in New Issue
Block a user