]> xenbits.xensource.com Git - libvirt.git/commitdiff
Pass allocation number to callback
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 29 May 2008 18:47:00 +0000 (18:47 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 29 May 2008 18:47:00 +0000 (18:47 +0000)
ChangeLog
src/memory.c
src/memory.h
tests/testutils.c

index 21f0cb0571ece6283361a041fe1924f0f5f4c16d..d48140a383ee5fe31038057a2850403bd6b96c9a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu May 29 14:46:00 EST 2008 Daniel P. Berrange <berrange@redhat.com>
+
+       * src/memory.h, src/memory.c, tests/testutils.c: Pass allocation
+       number to hook callback
+
 Thu May 29 14:45:00 EST 2008 Daniel P. Berrange <berrange@redhat.com>
 
        * src/buf.c: Convert to use new memory allocation APIs
index 5a55f2acd4d43444b2a5e4a50d8b2d29e9d6746c..e044b859c1b04e8eafdf568c200add626d66157b 100644 (file)
@@ -30,7 +30,7 @@
 static int testMallocNext = 0;
 static int testMallocFailFirst = 0;
 static int testMallocFailLast = 0;
-static void (*testMallocHook)(void*) = NULL;
+static void (*testMallocHook)(int, void*) = NULL;
 static void *testMallocHookData = NULL;
 
 void virAllocTestInit(void)
@@ -45,7 +45,7 @@ int virAllocTestCount(void)
     return testMallocNext - 1;
 }
 
-void virAllocTestHook(void (*func)(void*), void *data)
+void virAllocTestHook(void (*func)(int, void*), void *data)
 {
     testMallocHook = func;
     testMallocHookData = data;
@@ -69,7 +69,7 @@ static int virAllocTestFail(void)
         testMallocNext <= testMallocFailLast;
 
     if (fail && testMallocHook)
-        (testMallocHook)(testMallocHookData);
+        (testMallocHook)(testMallocNext, testMallocHookData);
 
     testMallocNext++;
     return fail;
index 2331b11c1144d47e50c44d5ddfc4c762b935c642..5e9af20d6586028464fc35ecee89d231fefda45d 100644 (file)
@@ -83,7 +83,7 @@ void virFree(void *ptrptr);
 void virAllocTestInit(void);
 int virAllocTestCount(void);
 void virAllocTestOOM(int n, int m);
-void virAllocTestHook(void (*func)(void*), void *data);
+void virAllocTestHook(void (*func)(int, void*), void *data);
 #endif
 
 
index da24093ee06c2cdac4e2b22db7fb7f781c3b5203..6eea4981ff8a769a7d0b2e079d399f98dc2988d9 100644 (file)
@@ -293,7 +293,7 @@ virtTestErrorFuncQuiet(void *data ATTRIBUTE_UNUSED,
 { }
 
 static void
-virtTestErrorHook(void *data ATTRIBUTE_UNUSED)
+virtTestErrorHook(int n, void *data ATTRIBUTE_UNUSED)
 {
 #if TEST_OOM_TRACE
     void *trace[30];
@@ -304,7 +304,7 @@ virtTestErrorHook(void *data ATTRIBUTE_UNUSED)
     ntrace = backtrace(trace, ntrace);
     symbols = backtrace_symbols(trace, ntrace);
     if (symbols) {
-        fprintf(stderr, "Failing an allocation at:\n");
+        fprintf(stderr, "Failing allocation %d at:\n", n);
         for (i = 0 ; i < ntrace ; i++) {
             if (symbols[i])
                 fprintf(stderr, "  TRACE:  %s\n", symbols[i]);