File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ void *OSHMPI_malloc(size_t size)
11
11
{
12
12
void * ptr = NULL ;
13
13
14
+ if (size == 0 )
15
+ return ptr ;
16
+
14
17
OSHMPI_THREAD_ENTER_CS (& OSHMPI_global .symm_heap_mspace_cs );
15
18
ptr = mspace_malloc (OSHMPI_global .symm_heap_mspace , size );
16
19
OSHMPI_THREAD_EXIT_CS (& OSHMPI_global .symm_heap_mspace_cs );
@@ -49,6 +52,9 @@ void *OSHMPI_realloc(void *ptr, size_t size)
49
52
{
50
53
void * rptr = NULL ;
51
54
55
+ if (size == 0 && ptr == NULL )
56
+ return ptr ;
57
+
52
58
OSHMPI_THREAD_ENTER_CS (& OSHMPI_global .symm_heap_mspace_cs );
53
59
rptr = mspace_realloc (OSHMPI_global .symm_heap_mspace , ptr , size );
54
60
OSHMPI_THREAD_EXIT_CS (& OSHMPI_global .symm_heap_mspace_cs );
@@ -75,6 +81,9 @@ void *OSHMPI_calloc(size_t count, size_t size)
75
81
{
76
82
void * ptr = NULL ;
77
83
84
+ if (size == 0 )
85
+ return ptr ;
86
+
78
87
OSHMPI_THREAD_ENTER_CS (& OSHMPI_global .symm_heap_mspace_cs );
79
88
ptr = mspace_calloc (OSHMPI_global .symm_heap_mspace , count , size );
80
89
OSHMPI_THREAD_EXIT_CS (& OSHMPI_global .symm_heap_mspace_cs );
You can’t perform that action at this time.
0 commit comments