Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 05cf7e0

Browse files
committed
Added VCHECK compile time option that fills allocated and freed blocks
with garbage.
1 parent e86cbc4 commit 05cf7e0

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Mac/mwerks/malloc/malloc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ static char *rcsid = "$Id$";
5757
#define DEBUG2
5858
#define MSTATS
5959
#define RCHECK
60+
#define VCHECK
6061

6162
typedef unsigned char u_char;
6263
typedef unsigned long u_long;
@@ -221,6 +222,9 @@ malloc(nbytes)
221222
op->ov_size = (nbytes + RSLOP - 1) & ~(RSLOP - 1);
222223
op->ov_rmagic = RMAGIC;
223224
*(u_short *)((caddr_t)(op + 1) + op->ov_size) = RMAGIC;
225+
#endif
226+
#ifdef VCHECK
227+
memset((char *)(op+1), 0x41, nbytes);
224228
#endif
225229
return ((char *)(op + 1));
226230
}
@@ -286,6 +290,9 @@ free(cp)
286290
#ifdef RCHECK
287291
ASSERT(op->ov_rmagic == RMAGIC);
288292
ASSERT(*(u_short *)((caddr_t)(op + 1) + op->ov_size) == RMAGIC);
293+
#endif
294+
#ifdef VCHECK
295+
memset(cp, 43, op->ov_size);
289296
#endif
290297
size = op->ov_index;
291298
if ( size == 0xff ) {

0 commit comments

Comments
 (0)