mirror of https://github.com/PCSX2/pcsx2.git
Improved the safe_delete / safe_free macros to avoid potential block scoping pitfalls, and fixed what looks to have been a minor typo in Tags.h :)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1640 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
5c187ebed7
commit
761e36796a
|
@ -29,40 +29,31 @@ extern void pcsx2_aligned_free(void* pmem);
|
|||
# define _aligned_realloc pcsx2_aligned_realloc
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Safe deallocation macros -- always check pointer validity (non-null)
|
||||
// and set pointer to null on deallocation.
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Safe deallocation macros -- always check pointer validity (non-null) when needed,
|
||||
// and set pointer to null after deallocation.
|
||||
|
||||
#define safe_delete( ptr ) \
|
||||
if( ptr != NULL ) { \
|
||||
delete ptr; \
|
||||
ptr = NULL; \
|
||||
}
|
||||
((void) (( ( ptr != NULL ) && (delete ptr, !!0) ), ptr = NULL))
|
||||
|
||||
#define safe_delete_array( ptr ) \
|
||||
if( ptr != NULL ) { \
|
||||
delete[] ptr; \
|
||||
ptr = NULL; \
|
||||
}
|
||||
((void) (( ( ptr != NULL ) && (delete[] ptr, !!0) ), ptr = NULL))
|
||||
|
||||
// fixme: I'm pretty sure modern libc implementations inder gcc and msvc check null status
|
||||
// inside free(), meaning we shouldn't have to do it ourselves. But legacy implementations
|
||||
// didn't always check, so best to be cautious unless absolutely certain it's being covered on
|
||||
// all ported platforms.
|
||||
#define safe_free( ptr ) \
|
||||
if( ptr != NULL ) { \
|
||||
free( ptr ); \
|
||||
ptr = NULL; \
|
||||
}
|
||||
((void) (( ( ptr != NULL ) && (free( ptr ), !!0) ), ptr = NULL))
|
||||
|
||||
// Implementation note: all known implementations of _aligned_free check the pointer for
|
||||
// NULL status (our implementation under GCC, and microsoft's under MSVC), so no need to
|
||||
// do it here.
|
||||
#define safe_aligned_free( ptr ) \
|
||||
if( ptr != NULL ) { \
|
||||
_aligned_free( ptr ); \
|
||||
ptr = NULL; \
|
||||
}
|
||||
( (void) ( _aligned_free( ptr ), ptr = NULL ) )
|
||||
|
||||
#define SafeSysMunmap( ptr, size ) \
|
||||
if( ptr != NULL ) { \
|
||||
HostSys::Munmap( (uptr)ptr, size ); \
|
||||
ptr = NULL; \
|
||||
}
|
||||
|
||||
( (void) ( HostSys::Munmap( (uptr)ptr, size ), ptr = NULL ) )
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Handy little class for allocating a resizable memory block, complete with
|
||||
|
|
|
@ -247,6 +247,6 @@ namespace QWC
|
|||
|
||||
static __forceinline void Clear(DMACh *tag)
|
||||
{
|
||||
tag->qwc == 0;
|
||||
tag->qwc = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,15 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GSdx", "plugins\GSdx\GSdx.v
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xpad", "plugins\xpad\xpad.vcxproj", "{6F3C4136-5801-4EBC-AC6E-37DF6FAB150A}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{06C9589C-DFD3-4CE8-B69A-32208C2767B2}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
common\include\afxresmw.h = common\include\afxresmw.h
|
||||
common\include\Pcsx2Api.h = common\include\Pcsx2Api.h
|
||||
common\include\Pcsx2Config.h = common\include\Pcsx2Config.h
|
||||
common\include\Pcsx2Defs.h = common\include\Pcsx2Defs.h
|
||||
common\include\Pcsx2Types.h = common\include\Pcsx2Types.h
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
|
|
Loading…
Reference in New Issue