Mercurial > SDL_sound_CoreAudio
comparison extra_rwops.c @ 491:8e9720b66e55
Patched to compile on more severe compilers.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Wed, 14 Sep 2005 20:01:50 +0000 |
parents | c7ab783f05d3 |
children | 2df1f5c62d38 |
comparison
equal
deleted
inserted
replaced
490:c7ab783f05d3 | 491:8e9720b66e55 |
---|---|
136 */ | 136 */ |
137 | 137 |
138 static SDL_RWops *rwops_pool = NULL; | 138 static SDL_RWops *rwops_pool = NULL; |
139 static SDL_mutex *rwops_pool_mutex = NULL; | 139 static SDL_mutex *rwops_pool_mutex = NULL; |
140 | 140 |
141 SDL_RWops *RWops_pooled_alloc(void) | |
142 { | |
143 SDL_RWops *rw; | |
144 if (rwops_pool_mutex == NULL) | |
145 return(NULL); /* never initialized. */ | |
146 | |
147 SDL_LockMutex(rwops_pool_mutex); | |
148 rw = rwops_pool; | |
149 if (rw) | |
150 rwops_pool = (SDL_RWops *) (rw->hidden.unknown.data1); | |
151 SDL_UnlockMutex(rwops_pool_mutex); | |
152 | |
153 if (!rw) | |
154 rw = (SDL_RWops *) malloc(sizeof (SDL_RWops)); | |
155 | |
156 return(rw); | |
157 } /* RWops_pooled_alloc */ | |
158 | |
159 | |
160 void RWops_pooled_free(SDL_RWops *rw) | |
161 { | |
162 if (rwops_pool_mutex == NULL) | |
163 return; /* never initialized...why are we here? */ | |
164 | |
165 if (rw == NULL) | |
166 return; | |
167 | |
168 SDL_LockMutex(rwops_pool_mutex); | |
169 rw->hidden.unknown.data1 = rwops_pool; | |
170 rwops_pool = rw; | |
171 SDL_UnlockMutex(rwops_pool_mutex); | |
172 } /* RWops_pooled_free */ | |
173 | |
174 | |
141 int RWops_pooled_init(void) | 175 int RWops_pooled_init(void) |
142 { | 176 { |
143 const int preallocate = 50; | 177 const int preallocate = 50; |
144 int i; | 178 int i; |
145 | 179 |
176 free(cur); | 210 free(cur); |
177 cur = next; | 211 cur = next; |
178 } /* while */ | 212 } /* while */ |
179 } /* RWops_pooled_deinit */ | 213 } /* RWops_pooled_deinit */ |
180 | 214 |
181 | |
182 SDL_RWops *RWops_pooled_alloc(void) | |
183 { | |
184 SDL_RWops *rw; | |
185 if (rwops_pool_mutex == NULL) | |
186 return(NULL); /* never initialized. */ | |
187 | |
188 SDL_LockMutex(rwops_pool_mutex); | |
189 rw = rwops_pool; | |
190 if (rw) | |
191 rwops_pool = (SDL_RWops *) (rw->hidden.unknown.data1); | |
192 SDL_UnlockMutex(rwops_pool_mutex); | |
193 | |
194 if (!rw) | |
195 rw = (SDL_RWops *) malloc(sizeof (SDL_RWops)); | |
196 | |
197 return(rw); | |
198 } /* RWops_pooled_alloc */ | |
199 | |
200 | |
201 void RWops_pooled_free(SDL_RWops *rw) | |
202 { | |
203 if (rwops_pool_mutex == NULL) | |
204 return; /* never initialized...why are we here? */ | |
205 | |
206 if (rw == NULL) | |
207 return; | |
208 | |
209 SDL_LockMutex(rwops_pool_mutex); | |
210 rw->hidden.unknown.data1 = rwops_pool; | |
211 rwops_pool = rw; | |
212 SDL_UnlockMutex(rwops_pool_mutex); | |
213 } /* RWops_pooled_free */ | |
214 | |
215 /* end of extra_rwops.c ... */ | 215 /* end of extra_rwops.c ... */ |
216 | 216 |
217 | 217 |