Change includes and minor fixes
This commit is contained in:
1 parent
2a1b0abb2f
commit
eaa9987314
16 files changed
+98
-146
No files matched your search
+13
-44
@@ -40,7 +40,7 @@
|
||||
#endif
|
||||
#define xMemSet( type, len, ptr ) memset( ptr, 0, ( len ) * sizeof( type ) )
|
||||
|
||||
static inline void* xMallocMem( size_t nitems )
|
||||
[[deprecated]] static inline void* xMallocMem( size_t nitems )
|
||||
{
|
||||
void* d;
|
||||
if( ( d = xMalloc( nitems ) ) == NULL )
|
||||
@@ -51,7 +51,7 @@ static inline void* xMallocMem( size_t nitems )
|
||||
return d;
|
||||
}
|
||||
|
||||
static inline void* xCallocMem( size_t nitems, size_t size )
|
||||
[[deprecated]] static inline void* xCallocMem( size_t nitems, size_t size )
|
||||
{
|
||||
size_t padded_size = nitems * size;
|
||||
void* d = xMallocMem( padded_size );
|
||||
@@ -61,7 +61,7 @@ static inline void* xCallocMem( size_t nitems, size_t size )
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int getMem1D( T** array1D, int dim0 )
|
||||
[[deprecated]] int getMem1D( T** array1D, int dim0 )
|
||||
{
|
||||
if( ( *array1D = (T*)xCallocMem( dim0, sizeof( T ) ) ) == NULL )
|
||||
return 0;
|
||||
@@ -69,6 +69,16 @@ int getMem1D( T** array1D, int dim0 )
|
||||
return ( sizeof( T* ) + dim0 * sizeof( T ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
[[deprecated]] void freeMem1D( T*& array1D )
|
||||
{
|
||||
if( array1D )
|
||||
{
|
||||
xFreeMem( array1D );
|
||||
array1D = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int getMem2D( T*** array2D, int dim0, int dim1 )
|
||||
{
|
||||
@@ -85,32 +95,6 @@ int getMem2D( T*** array2D, int dim0, int dim1 )
|
||||
return dim0 * ( sizeof( T* ) + dim1 * sizeof( T ) );
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int getMem3D( T**** array3D, int dim0, int dim1, int dim2 )
|
||||
{
|
||||
int i, mem_size = dim0 * sizeof( T** );
|
||||
|
||||
if( ( ( *array3D ) = (T***)xMallocMem( dim0 * sizeof( T** ) ) ) == NULL )
|
||||
printf( "get_mem3Dint: array3D" );
|
||||
|
||||
mem_size += getMem2D( *array3D, dim0 * dim1, dim2 );
|
||||
|
||||
for( i = 1; i < dim0; i++ )
|
||||
( *array3D )[i] = ( *array3D )[i - 1] + dim1;
|
||||
|
||||
return mem_size;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void freeMem1D( T*& array1D )
|
||||
{
|
||||
if( array1D )
|
||||
{
|
||||
xFreeMem( array1D );
|
||||
array1D = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void freeMem2D( T**& array2D )
|
||||
{
|
||||
@@ -130,19 +114,4 @@ void freeMem2D( T**& array2D )
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void freeMem3D( T***& array3D )
|
||||
{
|
||||
if( array3D )
|
||||
{
|
||||
freeMem2D( *array3D );
|
||||
xFreeMem( array3D );
|
||||
array3D = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf( "free_mem3Dint: trying to free unused memory" );
|
||||
}
|
||||
}
|
||||
|
||||
#endif // __LIBMEMORY_H__
|
||||
Reference in new issue
Block a user