[svn:parrot] r46422 - branches/codestring/src/gc

bacek at svn.parrot.org bacek at svn.parrot.org
Sat May 8 22:54:00 UTC 2010


Author: bacek
Date: Sat May  8 22:53:59 2010
New Revision: 46422
URL: https://trac.parrot.org/parrot/changeset/46422

Log:
Fill allocated memory with some garbage to simplify tracing of memory errors

Modified:
   branches/codestring/src/gc/gc_ms.c

Modified: branches/codestring/src/gc/gc_ms.c
==============================================================================
--- branches/codestring/src/gc/gc_ms.c	Sat May  8 22:53:44 2010	(r46421)
+++ branches/codestring/src/gc/gc_ms.c	Sat May  8 22:53:59 2010	(r46422)
@@ -64,7 +64,8 @@
 
 PARROT_MALLOC
 PARROT_CANNOT_RETURN_NULL
-static void * gc_ms_allocate_memory_chunk(SHIM_INTERP, size_t size);
+static void * gc_ms_allocate_memory_chunk(PARROT_INTERP, size_t size)
+        __attribute__nonnull__(1);
 
 PARROT_MALLOC
 PARROT_CANNOT_RETURN_NULL
@@ -265,7 +266,8 @@
 #define ASSERT_ARGS_gc_ms_allocate_bufferlike_header \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
        PARROT_ASSERT_ARG(interp))
-#define ASSERT_ARGS_gc_ms_allocate_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
+#define ASSERT_ARGS_gc_ms_allocate_memory_chunk __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+       PARROT_ASSERT_ARG(interp))
 #define ASSERT_ARGS_gc_ms_allocate_memory_chunk_zeroed \
      __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
 #define ASSERT_ARGS_gc_ms_allocate_pmc_attributes __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
@@ -1346,7 +1348,7 @@
 PARROT_MALLOC
 PARROT_CANNOT_RETURN_NULL
 static void *
-gc_ms_allocate_memory_chunk(SHIM_INTERP, size_t size)
+gc_ms_allocate_memory_chunk(PARROT_INTERP, size_t size)
 {
     ASSERT_ARGS(gc_ms_allocate_memory_chunk)
     void * const ptr = malloc(size);
@@ -1355,6 +1357,14 @@
 #endif
     if (!ptr)
         PANIC_OUT_OF_MEM(size);
+
+#ifdef NDEBUG
+    UNUSED(interp);
+#else
+    /* Fill with garbage to identify memory problems early */
+    memset(ptr, size, 0xf);
+#endif
+
     return ptr;
 }
 


More information about the parrot-commits mailing list