version 1.4, 2015/04/20 18:19:49
|
version 1.5, 2015/09/25 20:24:20
|
|
|
#include "alloc.h" | #include "alloc.h" |
#include "field.h" | #include "field.h" |
#include "class.h" | #include "class.h" |
|
#include <pal/intsafe.h> |
#include <stdio.h> | #include <stdio.h> |
#ifdef _MSC_VER | #ifdef _MSC_VER |
#pragma prefast (disable: 28252) | #pragma prefast (disable: 28252) |
|
|
static MI_Uint32 _NUM_PAGES = INFINITE; | static MI_Uint32 _NUM_PAGES = INFINITE; |
| |
/* The minimum number of reserved properties for a dynamic instance */ | /* The minimum number of reserved properties for a dynamic instance */ |
static MI_Uint32 _CAPACITY = 32; |
static size_t _CAPACITY = 32; |
| |
/* Find capacity (lesser of _CAPACITY or x rounded to power of 2) */ | /* Find capacity (lesser of _CAPACITY or x rounded to power of 2) */ |
static MI_Uint32 _FindCapacity(MI_Uint32 x) |
static size_t _FindCapacity(size_t x) |
{ | { |
if (x <= _CAPACITY) | if (x <= _CAPACITY) |
return _CAPACITY; | return _CAPACITY; |
else | else |
{ | { |
MI_Uint32 r = x - 1; |
size_t r = x - 1; |
| |
r |= (r >> 1); | r |= (r >> 1); |
r |= (r >> 2); | r |= (r >> 2); |
|
|
| |
static MI_PropertyDecl** _ClonePropertyDecls( | static MI_PropertyDecl** _ClonePropertyDecls( |
MI_PropertyDecl** properties, | MI_PropertyDecl** properties, |
MI_Uint32 size, |
size_t size, |
Batch* batch) | Batch* batch) |
{ | { |
MI_PropertyDecl** data; | MI_PropertyDecl** data; |
MI_Uint32 i; | MI_Uint32 i; |
| |
/* Allocate at least _CAPACITY properties */ | /* Allocate at least _CAPACITY properties */ |
MI_Uint32 cap = (size < _CAPACITY) ? _CAPACITY : size; |
size_t cap = (size < _CAPACITY) ? _CAPACITY : size; |
| |
/* Allocate properties array */ | /* Allocate properties array */ |
data = (MI_PropertyDecl**)BAlloc(batch, sizeof(MI_PropertyDecl*) * cap, | data = (MI_PropertyDecl**)BAlloc(batch, sizeof(MI_PropertyDecl*) * cap, |