CVS: winex/libs/ptmalloc3 malloc.c,1.2,1.3
| Newsgroups | gmane.comp.emulators.winex.cvs |
|---|---|
| Message-ID | <[email protected]> |
Subject: winex/libs/ptmalloc3 malloc.c,1.2,1.3Update of /var/lib/cvsd/cvsroot/winex/libs/ptmalloc3
In directory agravaine:/tmp/cvs-serv7290/libs/ptmalloc3
Modified Files:
malloc.c
Log Message:
- ensure a realloc to a smaller size doesn't move the memory block with the new allocator
Index: malloc.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/libs/ptmalloc3/malloc.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- malloc.c 30 Mar 2007 19:01:59 -0000 1.2
+++ malloc.c 30 Mar 2007 19:02:29 -0000 1.3
@@ -3612,10 +3612,18 @@
size_t oldsize = chunksize(oldp);
if (is_small(nb)) /* Can't shrink mmap regions below small size */
return 0;
+
+#ifndef TGCHANGES
/* Keep old chunk if big enough but not too big */
if (oldsize >= nb + SIZE_T_SIZE &&
(oldsize - nb) <= (mparams.granularity << 1))
return oldp;
+#else
+ /* Keep old chunk if big enough - we don't move or resize, as some games
+ assume that a realloc to a smaller value will keep the same pointer */
+ if (oldsize >= nb + SIZE_T_SIZE)
+ return oldp;
+#endif
else {
size_t offset = oldp->prev_foot & ~IS_MMAPPED_BIT;
size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD;