Skip to content

Commit

Permalink
Patched to compile on more severe compilers.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Sep 14, 2005
1 parent 8d3ef69 commit e3765f2
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions extra_rwops.c
Expand Up @@ -138,6 +138,40 @@ SDL_RWops *RWops_RWRefCounter_new(SDL_RWops *rw)
static SDL_RWops *rwops_pool = NULL;
static SDL_mutex *rwops_pool_mutex = NULL;

SDL_RWops *RWops_pooled_alloc(void)
{
SDL_RWops *rw;
if (rwops_pool_mutex == NULL)
return(NULL); /* never initialized. */

SDL_LockMutex(rwops_pool_mutex);
rw = rwops_pool;
if (rw)
rwops_pool = (SDL_RWops *) (rw->hidden.unknown.data1);
SDL_UnlockMutex(rwops_pool_mutex);

if (!rw)
rw = (SDL_RWops *) malloc(sizeof (SDL_RWops));

return(rw);
} /* RWops_pooled_alloc */


void RWops_pooled_free(SDL_RWops *rw)
{
if (rwops_pool_mutex == NULL)
return; /* never initialized...why are we here? */

if (rw == NULL)
return;

SDL_LockMutex(rwops_pool_mutex);
rw->hidden.unknown.data1 = rwops_pool;
rwops_pool = rw;
SDL_UnlockMutex(rwops_pool_mutex);
} /* RWops_pooled_free */


int RWops_pooled_init(void)
{
const int preallocate = 50;
Expand Down Expand Up @@ -178,40 +212,6 @@ void RWops_pooled_deinit(void)
} /* while */
} /* RWops_pooled_deinit */


SDL_RWops *RWops_pooled_alloc(void)
{
SDL_RWops *rw;
if (rwops_pool_mutex == NULL)
return(NULL); /* never initialized. */

SDL_LockMutex(rwops_pool_mutex);
rw = rwops_pool;
if (rw)
rwops_pool = (SDL_RWops *) (rw->hidden.unknown.data1);
SDL_UnlockMutex(rwops_pool_mutex);

if (!rw)
rw = (SDL_RWops *) malloc(sizeof (SDL_RWops));

return(rw);
} /* RWops_pooled_alloc */


void RWops_pooled_free(SDL_RWops *rw)
{
if (rwops_pool_mutex == NULL)
return; /* never initialized...why are we here? */

if (rw == NULL)
return;

SDL_LockMutex(rwops_pool_mutex);
rw->hidden.unknown.data1 = rwops_pool;
rwops_pool = rw;
SDL_UnlockMutex(rwops_pool_mutex);
} /* RWops_pooled_free */

/* end of extra_rwops.c ... */


0 comments on commit e3765f2

Please sign in to comment.