mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-13 00:01:55 +00:00
Pass allocation number to callback
This commit is contained in:
parent
46f52f32b2
commit
e8a0db81ef
@ -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
|
||||
|
@ -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]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user