# HG changeset patch # User Ryan C. Gordon # Date 1126728110 0 # Node ID 8e9720b66e557360d19441de8c9ed99fcb0b2bc3 # Parent c7ab783f05d3e6b7bbe9c66dd0c9406326270aa9 Patched to compile on more severe compilers. diff -r c7ab783f05d3 -r 8e9720b66e55 extra_rwops.c --- a/extra_rwops.c Wed Sep 14 16:01:27 2005 +0000 +++ b/extra_rwops.c Wed Sep 14 20:01:50 2005 +0000 @@ -138,6 +138,40 @@ 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; @@ -178,40 +212,6 @@ } /* 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 ... */