Add userData pointer to reallocateFn (#788)

* Add userData ptr to all reallocateFn calls
* Check that userData is correctly passed
* Update AUTHORS
This commit is contained in:
Kolja Kube
2020-12-03 20:46:22 +01:00
committed by GitHub
parent a11d66cbd3
commit 84b29e6995
6 changed files with 29 additions and 9 deletions

View File

@ -5,6 +5,18 @@
static const char* data = "my user data";
static const char* otherData = "other user data";
void* testReallocateFn(void* ptr, size_t newSize, void* userData) {
if (strcmp(userData, data) != 0) return NULL;
if (newSize == 0)
{
free(ptr);
return NULL;
}
return realloc(ptr, newSize);
}
static void test(WrenVM* vm)
{
WrenConfiguration configuration;
@ -17,6 +29,7 @@ static void test(WrenVM* vm)
return;
}
configuration.reallocateFn = testReallocateFn;
configuration.userData = (void*)data;
WrenVM* otherVM = wrenNewVM(&configuration);