diff --git a/test/controls.c b/test/controls.c index 0dca0f65..b4bb5309 100644 --- a/test/controls.c +++ b/test/controls.c @@ -17,12 +17,18 @@ static void testVtableFree(uiControl *c, void *implData) // do nothing } -static void createTestVtable(uiControlVtable *vtable) +uiControlVtable *allocVtableFull(testingT *t, const char *file, long line) { - memset(vtable, 0, sizeof (uiControlVtable)); - vtable->Size = sizeof (uiControlVtable); - vtable->Init = testVtableInit; - vtable->Free = testVtableFree; + uiControlVtable *v; + + v = (uiControlVtable *) malloc(sizeof (uiControlVtable)); + if (v == NULL) + testingTFatalfFull(t, file, line, "memory exhausted allocating uiControlVtable"); + memset(v, 0, sizeof (uiControlVtable)); + v->Size = sizeof (uiControlVtable); + v->Init = testVtableInit; + v->Free = testVtableFree; + return v; } struct checkControlErrorsParams { diff --git a/test/test.h b/test/test.h index 8a694852..81914a28 100644 --- a/test/test.h +++ b/test/test.h @@ -39,5 +39,7 @@ extern void checkProgrammerErrorFull(testingT *t, const char *file, long line, c #define checkProgrammerErrorInThread(t, name, f, data, msgWant) checkProgrammerErrorFull(t, __FILE__, __LINE__, name, f, data, msgWant, true) // controls.c +extern uiControlVtable *allocVtableFull(testingT *t, const char *file, long line); +#define allocVtable(t) allocVtableFull(t, __FILE__, __LINE__) extern uiControlOSVtable *allocOSVtableFull(testingT *t, const char *file, long line); #define allocOSVtable(t) allocOSVtableFull(t, __FILE__, __LINE__)