From f3b0dc16ab0e570e3a57a2cb145b814bc028bd8f Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 13 Jun 2019 10:31:17 -0400 Subject: [PATCH] Slight refactoring of the controls test. One more thing to do for now. --- test/controls.c | 16 +++++++++++----- test/test.h | 2 ++ 2 files changed, 13 insertions(+), 5 deletions(-) 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__)