提交 e8a0db81 编写于 作者: D Daniel P. Berrange

Pass allocation number to callback

上级 46f52f32
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
......
......@@ -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;
......
......@@ -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
......
......@@ -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]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册