8016105: Add complementary RETURN_NULL allocation macros in allocation.hpp

Sat, 15 Jun 2013 13:17:36 +0200

author
mgronlun
date
Sat, 15 Jun 2013 13:17:36 +0200
changeset 5269
abbd5c660b48
parent 5268
7fa28f3d3f62
child 5270
cd2118b62475

8016105: Add complementary RETURN_NULL allocation macros in allocation.hpp
Reviewed-by: sla, rbackman

src/share/vm/memory/allocation.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/memory/allocation.hpp	Fri Jun 14 22:34:08 2013 -0700
     1.2 +++ b/src/share/vm/memory/allocation.hpp	Sat Jun 15 13:17:36 2013 +0200
     1.3 @@ -635,8 +635,15 @@
     1.4  #define NEW_RESOURCE_ARRAY_IN_THREAD(thread, type, size)\
     1.5    (type*) resource_allocate_bytes(thread, (size) * sizeof(type))
     1.6  
     1.7 +#define NEW_RESOURCE_ARRAY_IN_THREAD_RETURN_NULL(thread, type, size)\
     1.8 +  (type*) resource_allocate_bytes(thread, (size) * sizeof(type), AllocFailStrategy::RETURN_NULL)
     1.9 +
    1.10  #define REALLOC_RESOURCE_ARRAY(type, old, old_size, new_size)\
    1.11 -  (type*) resource_reallocate_bytes((char*)(old), (old_size) * sizeof(type), (new_size) * sizeof(type) )
    1.12 +  (type*) resource_reallocate_bytes((char*)(old), (old_size) * sizeof(type), (new_size) * sizeof(type))
    1.13 +
    1.14 +#define REALLOC_RESOURCE_ARRAY_RETURN_NULL(type, old, old_size, new_size)\
    1.15 +  (type*) resource_reallocate_bytes((char*)(old), (old_size) * sizeof(type),\
    1.16 +                                    (new_size) * sizeof(type), AllocFailStrategy::RETURN_NULL)
    1.17  
    1.18  #define FREE_RESOURCE_ARRAY(type, old, size)\
    1.19    resource_free_bytes((char*)(old), (size) * sizeof(type))
    1.20 @@ -647,28 +654,40 @@
    1.21  #define NEW_RESOURCE_OBJ(type)\
    1.22    NEW_RESOURCE_ARRAY(type, 1)
    1.23  
    1.24 +#define NEW_RESOURCE_OBJ_RETURN_NULL(type)\
    1.25 +  NEW_RESOURCE_ARRAY_RETURN_NULL(type, 1)
    1.26 +
    1.27 +#define NEW_C_HEAP_ARRAY3(type, size, memflags, pc, allocfail)\
    1.28 +  (type*) AllocateHeap(size * sizeof(type), memflags, pc, allocfail)
    1.29 +
    1.30 +#define NEW_C_HEAP_ARRAY2(type, size, memflags, pc)\
    1.31 +  (type*) (AllocateHeap((size) * sizeof(type), memflags, pc))
    1.32 +
    1.33  #define NEW_C_HEAP_ARRAY(type, size, memflags)\
    1.34    (type*) (AllocateHeap((size) * sizeof(type), memflags))
    1.35  
    1.36 +#define NEW_C_HEAP_ARRAY2_RETURN_NULL(type, size, memflags, pc)\
    1.37 +  NEW_C_HEAP_ARRAY3(type, size, memflags, pc, AllocFailStrategy::RETURN_NULL)
    1.38 +
    1.39 +#define NEW_C_HEAP_ARRAY_RETURN_NULL(type, size, memflags)\
    1.40 +  NEW_C_HEAP_ARRAY3(type, size, memflags, (address)0, AllocFailStrategy::RETURN_NULL)
    1.41 +
    1.42  #define REALLOC_C_HEAP_ARRAY(type, old, size, memflags)\
    1.43    (type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags))
    1.44  
    1.45 +#define REALLOC_C_HEAP_ARRAY_RETURN_NULL(type, old, size, memflags)\
    1.46 +   (type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags, AllocFailStrategy::RETURN_NULL))
    1.47 +
    1.48  #define FREE_C_HEAP_ARRAY(type, old, memflags) \
    1.49    FreeHeap((char*)(old), memflags)
    1.50  
    1.51 -#define NEW_C_HEAP_ARRAY2(type, size, memflags, pc)\
    1.52 -  (type*) (AllocateHeap((size) * sizeof(type), memflags, pc))
    1.53 -
    1.54 -#define REALLOC_C_HEAP_ARRAY2(type, old, size, memflags, pc)\
    1.55 -  (type*) (ReallocateHeap((char*)old, (size) * sizeof(type), memflags, pc))
    1.56 -
    1.57 -#define NEW_C_HEAP_ARRAY3(type, size, memflags, pc, allocfail)         \
    1.58 -  (type*) AllocateHeap(size * sizeof(type), memflags, pc, allocfail)
    1.59 -
    1.60  // allocate type in heap without calling ctor
    1.61  #define NEW_C_HEAP_OBJ(type, memflags)\
    1.62    NEW_C_HEAP_ARRAY(type, 1, memflags)
    1.63  
    1.64 +#define NEW_C_HEAP_OBJ_RETURN_NULL(type, memflags)\
    1.65 +  NEW_C_HEAP_ARRAY_RETURN_NULL(type, 1, memflags)
    1.66 +
    1.67  // deallocate obj of type in heap without calling dtor
    1.68  #define FREE_C_HEAP_OBJ(objname, memflags)\
    1.69    FreeHeap((char*)objname, memflags);

mercurial