[Gridflow-cvs] [svn] commit: r3726 - /trunk/gridflow.c

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Fri May 30 15:18:03 EDT 2008


Author: matju
Date: Fri May 30 15:18:03 2008
New Revision: 3726

Log:
optional malloc trace using the DEBUG macro

Modified:
    trunk/gridflow.c

Modified: trunk/gridflow.c
==============================================================================
--- trunk/gridflow.c (original)
+++ trunk/gridflow.c Fri May 30 15:18:03 2008
@@ -176,15 +176,37 @@
 	for (; n; in++, out++, n--) { *out = *in; }
 }
 
+//----------------------------------------------------------------
+
+//#define DEBUG
+
 extern "C" {
-void *gfmalloc(size_t n) {
+    void *gfmalloc(size_t n) {
+#ifdef DEBUG
+	static long cumul=0;
+	uint64 t = gf_timeofday();
+#endif
 	void *p = memalign(16,n);
 	long align = (long)p & 15;
 	if (align) fprintf(stderr,"malloc alignment = %ld mod 16\n",align);
+#ifdef DEBUG
+	t = gf_timeofday() - t; cumul += t; post("malloc p=%p bytes=%ld time=%ld cumul=%ld",p,(long)n,(long)t,(long)cumul);
+#endif
 	return p;
-}
-void gffree(void *p) {free(p);}
+    }
+    void gffree(void *p) {
+#ifdef DEBUG
+	static long cumul=0;
+	uint64 t = gf_timeofday();
+#endif
+	free(p);
+#ifdef DEBUG
+	t = gf_timeofday() - t; cumul += t; post("free   p=%p           time=%ld cumul=%ld",p,        (long)t,(long)cumul);
+#endif
+    }
 };
+
+//----------------------------------------------------------------
 
 uint64 gf_timeofday () {
 	timeval t;



More information about the Gridflow-cvs mailing list