Some tweaks to PHYSFS_Allocator.
This commit is contained in:
parent
0d43bf1eb1
commit
67746179d3
|
@ -2,6 +2,7 @@
|
||||||
* CHANGELOG.
|
* CHANGELOG.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
09092005 - Some tweaks to PHYSFS_Allocator.
|
||||||
09062005 - Happy September. Changed the allocation abstraction to use
|
09062005 - Happy September. Changed the allocation abstraction to use
|
||||||
PHYSFS_uint64 instead of size_t, so we don't have to include
|
PHYSFS_uint64 instead of size_t, so we don't have to include
|
||||||
system headers inside physfs.h. Minor MingW fixes (but it's still
|
system headers inside physfs.h. Minor MingW fixes (but it's still
|
||||||
|
|
8
physfs.c
8
physfs.c
|
@ -777,7 +777,8 @@ int PHYSFS_init(const char *argv0)
|
||||||
if (!externalAllocator)
|
if (!externalAllocator)
|
||||||
setDefaultAllocator();
|
setDefaultAllocator();
|
||||||
|
|
||||||
BAIL_IF_MACRO(!allocator.Init(), NULL, 0);
|
if (allocator.Init != NULL)
|
||||||
|
BAIL_IF_MACRO(!allocator.Init(), NULL, 0);
|
||||||
|
|
||||||
BAIL_IF_MACRO(!__PHYSFS_platformInit(), NULL, 0);
|
BAIL_IF_MACRO(!__PHYSFS_platformInit(), NULL, 0);
|
||||||
|
|
||||||
|
@ -889,7 +890,8 @@ int PHYSFS_deinit(void)
|
||||||
__PHYSFS_platformDestroyMutex(errorLock);
|
__PHYSFS_platformDestroyMutex(errorLock);
|
||||||
__PHYSFS_platformDestroyMutex(stateLock);
|
__PHYSFS_platformDestroyMutex(stateLock);
|
||||||
|
|
||||||
allocator.Deinit();
|
if (allocator.Deinit != NULL)
|
||||||
|
allocator.Deinit();
|
||||||
|
|
||||||
errorLock = stateLock = NULL;
|
errorLock = stateLock = NULL;
|
||||||
return(1);
|
return(1);
|
||||||
|
@ -2047,7 +2049,7 @@ int PHYSFS_flush(PHYSFS_File *handle)
|
||||||
} /* PHYSFS_flush */
|
} /* PHYSFS_flush */
|
||||||
|
|
||||||
|
|
||||||
int PHYSFS_setAllocator(PHYSFS_Allocator *a)
|
int PHYSFS_setAllocator(const PHYSFS_Allocator *a)
|
||||||
{
|
{
|
||||||
BAIL_IF_MACRO(initialized, ERR_IS_INITIALIZED, 0);
|
BAIL_IF_MACRO(initialized, ERR_IS_INITIALIZED, 0);
|
||||||
externalAllocator = (a != NULL);
|
externalAllocator = (a != NULL);
|
||||||
|
|
16
physfs.h
16
physfs.h
|
@ -1847,7 +1847,7 @@ __EXPORT__ int PHYSFS_writeUBE64(PHYSFS_File *file, PHYSFS_uint64 val);
|
||||||
/* Everything above this line is part of the PhysicsFS 1.0 API. */
|
/* Everything above this line is part of the PhysicsFS 1.0 API. */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \struct PHYSFS_allocator
|
* \struct PHYSFS_Allocator
|
||||||
* \brief PhysicsFS allocation function pointers.
|
* \brief PhysicsFS allocation function pointers.
|
||||||
*
|
*
|
||||||
* (This is for limited, hardcore use. If you don't immediately see a need
|
* (This is for limited, hardcore use. If you don't immediately see a need
|
||||||
|
@ -1868,16 +1868,16 @@ __EXPORT__ int PHYSFS_writeUBE64(PHYSFS_File *file, PHYSFS_uint64 val);
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int (*Init)(void);
|
int (*Init)(void); /**< Initialize. Can be NULL. Zero on failure. */
|
||||||
void (*Deinit)(void);
|
void (*Deinit)(void); /**< Deinitialize your allocator. Can be NULL. */
|
||||||
void *(*Malloc)(PHYSFS_uint64);
|
void *(*Malloc)(PHYSFS_uint64); /**< Allocate like malloc(). */
|
||||||
void *(*Realloc)(void *, PHYSFS_uint64);
|
void *(*Realloc)(void *, PHYSFS_uint64); /**< Reallocate like realloc(). */
|
||||||
void (*Free)(void *);
|
void (*Free)(void *); /**< Free memory from Malloc or Realloc. */
|
||||||
} PHYSFS_Allocator;
|
} PHYSFS_Allocator;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \fn int PHYSFS_setAllocator(PHYSFS_Allocator *allocator)
|
* \fn int PHYSFS_setAllocator(const PHYSFS_Allocator *allocator)
|
||||||
* \brief Hook your own allocation routines into PhysicsFS.
|
* \brief Hook your own allocation routines into PhysicsFS.
|
||||||
*
|
*
|
||||||
* (This is for limited, hardcore use. If you don't immediately see a need
|
* (This is for limited, hardcore use. If you don't immediately see a need
|
||||||
|
@ -1903,7 +1903,7 @@ typedef struct
|
||||||
* \return zero on failure, non-zero on success. This call only fails
|
* \return zero on failure, non-zero on success. This call only fails
|
||||||
* when used between PHYSFS_init() and PHYSFS_deinit() calls.
|
* when used between PHYSFS_init() and PHYSFS_deinit() calls.
|
||||||
*/
|
*/
|
||||||
__EXPORT__ int PHYSFS_setAllocator(PHYSFS_Allocator *allocator);
|
__EXPORT__ int PHYSFS_setAllocator(const PHYSFS_Allocator *allocator);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue