Memory allocation functions
Allocates memory
XS_EXPORT void * XSAllocWithInfos(
size_t bytes,
XSClassID classID,
const char *file,
int line,
const char *func );
Do not use this function directly. Use the XSAlloc macro instead.
The allocated memory, or NULL
Allocates memory which will be automatically released
XS_EXPORT XS_AUTORELEASED void * XSAutoAllocWithInfos(
size_t bytes,
XSClassID classID,
const char *file,
int line,
const char *func );
Do not use this function directly. Use the XSAutoAlloc macro instead.
The allocated memory, or NULL
Auto-releases memory data
XS_EXPORT void * XSAutorelease(
const void *memory );
The memory data will be placed in the instance of the current auto-release pool, and will be released the next time the auto-release pool is drained.
The memory data
Copies a memory data object
XS_EXPORT void * XSCopyWithInfos(
const void *memory,
const char *file,
int line,
const char *func );
Do not use this function directly. Use the XSCopy macro instead.
The copy of the memory data object
Copies a memory data object
XS_EXPORT void * XSCopyWithInfos(
const void *memory,
const char *file,
int line,
const char *func );
Do not use this function directly. Use the XSCopy macro instead.
The copy of the memory data object
Checks whether two memory data objects are equals
XS_EXPORT bool XSEquals(
const void *memory1,
const void *memory2 );
True if both memory data objects are equals, otherwise false
Get the retain count of a memory data object
XS_EXPORT int64_t XSGetRetainCount(
const void *memory );
This functions is exposed for unit-tests and debug purposes. Never use it or rely on it in production code.
The object's retain count
Reallocates memory
XS_EXPORT void * XSReallocWithInfos(
const void *memory,
size_t bytes,
const char *file,
int line,
const char *func );
Do not use this function directly. Use the XSRealloc macro instead.
The reallocated memory, or NULL
Releases memory data
XS_EXPORT void XSReleaseWithInfos(
const void *memory,
const char *file,
int line,
const char *func );
Do not use this function directly. Use the XSRelease macro instead.
Retains memory data
XS_EXPORT void * XSRetainWithInfos(
const void *memory,
const char *file,
int line,
const char *func );
Do not use this function directly. Use the XSRelease macro instead.
The memory data
Retains memory data
XS_EXPORT void * XSRetainWithInfos(
const void *memory,
const char *file,
int line,
const char *func );
Do not use this function directly. Use the XSRelease macro instead.
The memory data
Allocates memory
#ifdef DEBUG
#define XSAlloc( _bytes_ ) XSAllocWithInfos( _bytes_, 0, __FILE__, __LINE__, __func__ )
#else
#define XSAlloc( _bytes_ ) XSAllocWithInfos( _bytes_, 0, NULL, 0, NULL )
#endif
The allocated memory will be zero-filled
The allocated memory, or NULL
Allocates memory which will be automatically released
#ifdef DEBUG
#define XSAutoAlloc( _bytes_ ) XSAutoAllocWithInfos( _bytes_, 0, __FILE__, __LINE__, __func__ )
#else
#define XSAutoAlloc( _bytes_ ) XSAutoAllocWithInfos( _bytes_, 0, NULL, 0, NULL )
#endif
The memory data will be placed in the instance of the current auto-release pool, and will be released the next time the auto-release pool is drained. The allocated memory will be zero-filled
The allocated memory, or NULL
Issues a fatal error message for a bad memory allocation
#define XSBadAlloc() XSFatalError( "Cannot allocate memory" )
Copies a memory data object
#ifdef DEBUG
#define XSCopy( _memory_ ) XSCopyWithInfos( _memory_, __FILE__, __LINE__, __func__ )
#else
#define XSCopy( _memory_ ) XSCopyWithInfos( _memory_, NULL, 0, NULL )
#endif
The copy of the memory data object
Reallocates memory
#ifdef DEBUG
#define XSRealloc( _memory_, _bytes_ ) XSReallocWithInfos( _memory_, _bytes_, __FILE__, __LINE__, __func__ )
#else
#define XSRealloc( _memory_, _bytes_ ) XSReallocWithInfos( _memory_, _bytes_, NULL, 0, NULL )
#endif
If the requested bytes are larger than the previous allocation size, additional data will be zero-filled.
The reallocated memory, or NULL
Releases memory data
#ifdef DEBUG
#define XSRelease( _memory_ ) XSReleaseWithInfos( _memory_, __FILE__, __LINE__, __func__ )
#else
#define XSRelease( _memory_ ) XSReleaseWithInfos( _memory_, NULL, 0, NULL )
#endif
Memory may be freed if the retain count for the memory data reaches 0.