]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
reallocing large blocks now doesn't copy if not needed
authorJack Jansen <jack.jansen@cwi.nl>
Sun, 22 Jan 1995 16:44:49 +0000 (16:44 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Sun, 22 Jan 1995 16:44:49 +0000 (16:44 +0000)
Mac/mwerks/malloc/malloc.c

index 5b644d7ce427a47d5890a1a0d6ebba7901593d48..754b1f7b7e54bd8eb22999732784c44a8278b65d 100644 (file)
@@ -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 )