Remove oldSize from allocate API.

binary_trees - wren            .......... 0.29s 0.0048 107.79% relative to baseline
delta_blue - wren              .......... 0.12s 0.0017 106.95% relative to baseline
fib - wren                     .......... 0.30s 0.0042 119.95% relative to baseline
for - wren                     .......... 0.12s 0.0020 107.57% relative to baseline
method_call - wren             .......... 0.15s 0.0256 106.09% relative to baseline
map_numeric - wren             .......... 0.44s 0.0199 105.27% relative to baseline
map_string - wren              .......... 0.14s 0.0049 100.18% relative to baseline
string_equals - wren           .......... 0.30s 0.0032 100.57% relative to baseline

Thanks, Michel!
This commit is contained in:
Bob Nystrom
2015-03-25 07:45:29 -07:00
parent 8c4e5eeea8
commit e4a785a071
3 changed files with 14 additions and 22 deletions
+3 -10
View File
@@ -18,22 +18,15 @@
#include <time.h>
#endif
// The built-in reallocation function used when one is not provided by the
// configuration.
static void* defaultReallocate(void* memory, size_t oldSize, size_t newSize)
{
return realloc(memory, newSize);
}
WrenVM* wrenNewVM(WrenConfiguration* configuration)
{
WrenReallocateFn reallocate = defaultReallocate;
WrenReallocateFn reallocate = realloc;
if (configuration->reallocateFn != NULL)
{
reallocate = configuration->reallocateFn;
}
WrenVM* vm = (WrenVM*)reallocate(NULL, 0, sizeof(*vm));
WrenVM* vm = (WrenVM*)reallocate(NULL, sizeof(*vm));
memset(vm, 0, sizeof(WrenVM));
vm->reallocate = reallocate;
@@ -209,7 +202,7 @@ void* wrenReallocate(WrenVM* vm, void* memory, size_t oldSize, size_t newSize)
if (newSize > 0 && vm->bytesAllocated > vm->nextGC) collectGarbage(vm);
#endif
return vm->reallocate(memory, oldSize, newSize);
return vm->reallocate(memory, newSize);
}
// Captures the local variable [local] into an [Upvalue]. If that local is