summaryrefslogtreecommitdiffstats
path: root/Mac/mwerks/malloc
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1995-01-22 16:44:49 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1995-01-22 16:44:49 (GMT)
commitf2e5129820686a2a34eb8a702999c2faf5c178c6 (patch)
tree24374aea60da55d7a8cb0026efe6fb88496ff0b1 /Mac/mwerks/malloc
parent8239f0ffa0ea6c605144145c6de45bbbb742f598 (diff)
downloadcpython-f2e5129820686a2a34eb8a702999c2faf5c178c6.zip
cpython-f2e5129820686a2a34eb8a702999c2faf5c178c6.tar.gz
cpython-f2e5129820686a2a34eb8a702999c2faf5c178c6.tar.bz2
reallocing large blocks now doesn't copy if not needed
Diffstat (limited to 'Mac/mwerks/malloc')
-rw-r--r--Mac/mwerks/malloc/malloc.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/Mac/mwerks/malloc/malloc.c b/Mac/mwerks/malloc/malloc.c
index 5b644d7..754b1f7 100644
--- a/Mac/mwerks/malloc/malloc.c
+++ b/Mac/mwerks/malloc/malloc.c
@@ -333,8 +333,21 @@ realloc(cp, nbytes)
*/
expensive = 0;
if ( i == 0xff ) {
- expensive = 1;
+ /* Big block. See if it has to stay big */
+ if (nbytes+OVERHEAD > MAXMALLOC) {
+ /* Yup, try to resize it first */
+ SetPtrSize((Ptr)op, nbytes+OVERHEAD);
+ if ( MemError() == 0 ) {
+#ifdef RCHECK
+ op->ov_size = (nbytes + RSLOP - 1) & ~(RSLOP - 1);
+ *(u_short *)((caddr_t)(op + 1) + op->ov_size) = RMAGIC;
+#endif
+ return cp;
+ }
+ /* Nope, failed. Take the long way */
+ }
maxsize = GetPtrSize((Ptr)op);
+ expensive = 1;
} else {
maxsize = 1 << (i+3);
if ( nbytes + OVERHEAD > maxsize )