mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
8016105: Add complementary RETURN_NULL allocation macros in allocation.hpp
Reviewed-by: sla, rbackman
This commit is contained in:
parent
c6b677315f
commit
08f43d4379
1 changed files with 31 additions and 12 deletions
|
@ -635,9 +635,16 @@ class ResourceObj ALLOCATION_SUPER_CLASS_SPEC {
|
||||||
#define NEW_RESOURCE_ARRAY_IN_THREAD(thread, type, size)\
|
#define NEW_RESOURCE_ARRAY_IN_THREAD(thread, type, size)\
|
||||||
(type*) resource_allocate_bytes(thread, (size) * sizeof(type))
|
(type*) resource_allocate_bytes(thread, (size) * sizeof(type))
|
||||||
|
|
||||||
|
#define NEW_RESOURCE_ARRAY_IN_THREAD_RETURN_NULL(thread, type, size)\
|
||||||
|
(type*) resource_allocate_bytes(thread, (size) * sizeof(type), AllocFailStrategy::RETURN_NULL)
|
||||||
|
|
||||||
#define REALLOC_RESOURCE_ARRAY(type, old, old_size, new_size)\
|
#define REALLOC_RESOURCE_ARRAY(type, old, old_size, new_size)\
|
||||||
(type*) resource_reallocate_bytes((char*)(old), (old_size) * sizeof(type), (new_size) * sizeof(type))
|
(type*) resource_reallocate_bytes((char*)(old), (old_size) * sizeof(type), (new_size) * sizeof(type))
|
||||||
|
|
||||||
|
#define REALLOC_RESOURCE_ARRAY_RETURN_NULL(type, old, old_size, new_size)\
|
||||||
|
(type*) resource_reallocate_bytes((char*)(old), (old_size) * sizeof(type),\
|
||||||
|
(new_size) * sizeof(type), AllocFailStrategy::RETURN_NULL)
|
||||||
|
|
||||||
#define FREE_RESOURCE_ARRAY(type, old, size)\
|
#define FREE_RESOURCE_ARRAY(type, old, size)\
|
||||||
resource_free_bytes((char*)(old), (size) * sizeof(type))
|
resource_free_bytes((char*)(old), (size) * sizeof(type))
|
||||||
|
|
||||||
|
@ -647,28 +654,40 @@ class ResourceObj ALLOCATION_SUPER_CLASS_SPEC {
|
||||||
#define NEW_RESOURCE_OBJ(type)\
|
#define NEW_RESOURCE_OBJ(type)\
|
||||||
NEW_RESOURCE_ARRAY(type, 1)
|
NEW_RESOURCE_ARRAY(type, 1)
|
||||||
|
|
||||||
#define NEW_C_HEAP_ARRAY(type, size, memflags)\
|
#define NEW_RESOURCE_OBJ_RETURN_NULL(type)\
|
||||||
(type*) (AllocateHeap((size) * sizeof(type), memflags))
|
NEW_RESOURCE_ARRAY_RETURN_NULL(type, 1)
|
||||||
|
|
||||||
#define REALLOC_C_HEAP_ARRAY(type, old, size, memflags)\
|
|
||||||
(type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags))
|
|
||||||
|
|
||||||
#define FREE_C_HEAP_ARRAY(type, old, memflags) \
|
|
||||||
FreeHeap((char*)(old), memflags)
|
|
||||||
|
|
||||||
#define NEW_C_HEAP_ARRAY2(type, size, memflags, pc)\
|
|
||||||
(type*) (AllocateHeap((size) * sizeof(type), memflags, pc))
|
|
||||||
|
|
||||||
#define REALLOC_C_HEAP_ARRAY2(type, old, size, memflags, pc)\
|
|
||||||
(type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags, pc))
|
|
||||||
|
|
||||||
#define NEW_C_HEAP_ARRAY3(type, size, memflags, pc, allocfail)\
|
#define NEW_C_HEAP_ARRAY3(type, size, memflags, pc, allocfail)\
|
||||||
(type*) AllocateHeap(size * sizeof(type), memflags, pc, allocfail)
|
(type*) AllocateHeap(size * sizeof(type), memflags, pc, allocfail)
|
||||||
|
|
||||||
|
#define NEW_C_HEAP_ARRAY2(type, size, memflags, pc)\
|
||||||
|
(type*) (AllocateHeap((size) * sizeof(type), memflags, pc))
|
||||||
|
|
||||||
|
#define NEW_C_HEAP_ARRAY(type, size, memflags)\
|
||||||
|
(type*) (AllocateHeap((size) * sizeof(type), memflags))
|
||||||
|
|
||||||
|
#define NEW_C_HEAP_ARRAY2_RETURN_NULL(type, size, memflags, pc)\
|
||||||
|
NEW_C_HEAP_ARRAY3(type, size, memflags, pc, AllocFailStrategy::RETURN_NULL)
|
||||||
|
|
||||||
|
#define NEW_C_HEAP_ARRAY_RETURN_NULL(type, size, memflags)\
|
||||||
|
NEW_C_HEAP_ARRAY3(type, size, memflags, (address)0, AllocFailStrategy::RETURN_NULL)
|
||||||
|
|
||||||
|
#define REALLOC_C_HEAP_ARRAY(type, old, size, memflags)\
|
||||||
|
(type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags))
|
||||||
|
|
||||||
|
#define REALLOC_C_HEAP_ARRAY_RETURN_NULL(type, old, size, memflags)\
|
||||||
|
(type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags, AllocFailStrategy::RETURN_NULL))
|
||||||
|
|
||||||
|
#define FREE_C_HEAP_ARRAY(type, old, memflags) \
|
||||||
|
FreeHeap((char*)(old), memflags)
|
||||||
|
|
||||||
// allocate type in heap without calling ctor
|
// allocate type in heap without calling ctor
|
||||||
#define NEW_C_HEAP_OBJ(type, memflags)\
|
#define NEW_C_HEAP_OBJ(type, memflags)\
|
||||||
NEW_C_HEAP_ARRAY(type, 1, memflags)
|
NEW_C_HEAP_ARRAY(type, 1, memflags)
|
||||||
|
|
||||||
|
#define NEW_C_HEAP_OBJ_RETURN_NULL(type, memflags)\
|
||||||
|
NEW_C_HEAP_ARRAY_RETURN_NULL(type, 1, memflags)
|
||||||
|
|
||||||
// deallocate obj of type in heap without calling dtor
|
// deallocate obj of type in heap without calling dtor
|
||||||
#define FREE_C_HEAP_OBJ(objname, memflags)\
|
#define FREE_C_HEAP_OBJ(objname, memflags)\
|
||||||
FreeHeap((char*)objname, memflags);
|
FreeHeap((char*)objname, memflags);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue