* nice_chunk and nice_chunk size need to be set
* and queried under the protection of sv_mutex
*/
-#define offer_nice_chunk(chunk, chunk_size) \
- STMT_START { \
- LOCK_SV_MUTEX; \
- if (!PL_nice_chunk) { \
- PL_nice_chunk = (char*)(chunk); \
- PL_nice_chunk_size = (chunk_size); \
- } \
- else if (chunk_size > PL_nice_chunk_size) { \
- Safefree(PL_nice_chunk); \
- PL_nice_chunk = (char*)(chunk); \
- PL_nice_chunk_size = (chunk_size); \
- } \
- else { \
- Safefree(chunk); \
- } \
- UNLOCK_SV_MUTEX; \
- } STMT_END
+#define offer_nice_chunk(chunk, chunk_size) STMT_START { \
+ void *new_chunk; \
+ U32 new_chunk_size; \
+ LOCK_SV_MUTEX; \
+ new_chunk = (void *)(chunk); \
+ new_chunk_size = (chunk_size); \
+ if (new_chunk_size > PL_nice_chunk_size) { \
+ if (PL_nice_chunk) Safefree(PL_nice_chunk); \
+ PL_nice_chunk = new_chunk; \
+ PL_nice_chunk_size = new_chunk_size; \
+ } else { \
+ Safefree(chunk); \
+ } \
+ UNLOCK_SV_MUTEX; \
+ } STMT_END
#ifdef HAS_SEM
# include <sys/ipc.h>
if (PL_nice_chunk) {
sv_add_arena(PL_nice_chunk, PL_nice_chunk_size, 0);
PL_nice_chunk = Nullch;
+ PL_nice_chunk_size = 0;
}
else {
char *chunk; /* must use New here to match call to */