store RMAGIC on a short boundary (if RCHECK defined).
authorRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Thu, 29 Nov 1984 02:08:43 +0000 (18:08 -0800)
committerRalph Campbell <ralph@ucbvax.Berkeley.EDU>
Thu, 29 Nov 1984 02:08:43 +0000 (18:08 -0800)
SCCS-vsn: lib/libc/stdlib/malloc.c 4.6

usr/src/lib/libc/stdlib/malloc.c

index f0037a6..05431a1 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)malloc.c   4.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)malloc.c   4.6 (Berkeley) %G%";
 #endif
 
 /*
 #endif
 
 /*
@@ -163,9 +163,9 @@ malloc(nbytes)
         * Record allocated size of block and
         * bound space with magic numbers.
         */
         * Record allocated size of block and
         * bound space with magic numbers.
         */
-       op->ov_size = nbytes;
+       op->ov_size = (nbytes + RSLOP - 1) & ~(RSLOP - 1);
        op->ov_rmagic = RMAGIC;
        op->ov_rmagic = RMAGIC;
-       *(u_short *)((caddr_t)(op + 1) + nbytes) = RMAGIC;
+       *(u_short *)((caddr_t)(op + 1) + op->ov_size) = RMAGIC;
 #endif
        return ((char *)(op + 1));
 }
 #endif
        return ((char *)(op + 1));
 }
@@ -298,7 +298,7 @@ realloc(cp, nbytes)
                }
                if (nbytes <= onb && nbytes > i) {
 #ifdef RCHECK
                }
                if (nbytes <= onb && nbytes > i) {
 #ifdef RCHECK
-                       op->ov_size = nbytes;
+                       op->ov_size = (nbytes + RSLOP - 1) & ~(RSLOP - 1);
                        *(u_short *)((caddr_t)(op + 1) + op->ov_size) = RMAGIC;
 #endif
                        return(cp);
                        *(u_short *)((caddr_t)(op + 1) + op->ov_size) = RMAGIC;
 #endif
                        return(cp);