mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-11 06:08:41 +01:00
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:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user