diff --git a/python/core/auto_generated/qgis.sip.in b/python/core/auto_generated/qgis.sip.in index 722a8427eda2..2f3225c239e8 100644 --- a/python/core/auto_generated/qgis.sip.in +++ b/python/core/auto_generated/qgis.sip.in @@ -869,7 +869,6 @@ QString qgsVsiPrefix( const QString &path ); - const long GEOSRID; const long GEOCRS_ID; diff --git a/src/core/qgis.cpp b/src/core/qgis.cpp index 7286006e08ba..62d2db6880d5 100644 --- a/src/core/qgis.cpp +++ b/src/core/qgis.cpp @@ -91,30 +91,22 @@ qlonglong qgsPermissiveToLongLong( QString string, bool &ok ) void *qgsMalloc( size_t size ) { - if ( size == 0 || long( size ) < 0 ) + if ( size == 0 ) { - QgsDebugMsg( QStringLiteral( "Negative or zero size %1." ).arg( size ) ); + QgsDebugMsg( QStringLiteral( "Zero size requested" ) ); return nullptr; } - void *p = malloc( size ); - if ( !p ) - { - QgsDebugMsg( QStringLiteral( "Allocation of %1 bytes failed." ).arg( size ) ); - } - return p; -} -void *qgsCalloc( size_t nmemb, size_t size ) -{ - if ( nmemb == 0 || long( nmemb ) < 0 || size == 0 || long( size ) < 0 ) + if ( ( size >> ( 8 * sizeof( size ) - 1 ) ) != 0 ) { - QgsDebugMsg( QStringLiteral( "Negative or zero nmemb %1 or size %2." ).arg( nmemb ).arg( size ) ); + QgsDebugMsg( QStringLiteral( "qgsMalloc - bad size requested: %1" ).arg( size ) ); return nullptr; } - void *p = qgsMalloc( nmemb * size ); - if ( p ) + + void *p = malloc( size ); + if ( !p ) { - memset( p, 0, nmemb * size ); + QgsDebugMsg( QStringLiteral( "Allocation of %1 bytes failed." ).arg( size ) ); } return p; } diff --git a/src/core/qgis.h b/src/core/qgis.h index 1405e02fc85e..9db739f5827d 100644 --- a/src/core/qgis.h +++ b/src/core/qgis.h @@ -1578,15 +1578,6 @@ CORE_EXPORT QString qgsVsiPrefix( const QString &path ); */ void CORE_EXPORT *qgsMalloc( size_t size ) SIP_SKIP; -/** - * Allocates memory for an array of nmemb elements of size bytes each and returns - * a pointer to the allocated memory. Works like C calloc() but prints debug message - * by QgsLogger if allocation fails. - * \param nmemb number of elements - * \param size size of element in bytes - */ -void CORE_EXPORT *qgsCalloc( size_t nmemb, size_t size ) SIP_SKIP; - /** * Frees the memory space pointed to by ptr. Works like C free(). * \param ptr pointer to memory space