Skip to content

Commit d55f3f3

Browse files
authored
Merge pull request #1464 from ldorau/Fix_nullAlloc_in_tests
Fix nullAlloc() in tests
2 parents fb7ec72 + ace1641 commit d55f3f3

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

test/common/provider_null.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
#include <assert.h>
66
#include <stdlib.h>
77

8-
#include "provider_null.h"
98
#include <umf/memory_provider_ops.h>
109

10+
#include "provider_null.h"
11+
#include "utils_common.h"
12+
1113
static umf_result_t nullInitialize(const void *params, void **pool) {
1214
(void)params;
1315
*pool = NULL;
@@ -22,9 +24,18 @@ static umf_result_t nullFinalize(void *pool) {
2224
static umf_result_t nullAlloc(void *provider, size_t size, size_t alignment,
2325
void **ptr) {
2426
(void)provider;
25-
(void)size;
26-
(void)alignment;
27-
*ptr = NULL;
27+
28+
if (ptr == NULL) {
29+
return UMF_RESULT_ERROR_INVALID_ARGUMENT;
30+
}
31+
32+
if (size == 0) {
33+
*ptr = NULL;
34+
return UMF_RESULT_SUCCESS;
35+
}
36+
37+
*ptr = (void *)ALIGN_UP_SAFE(0xDEADBEAF, alignment); // any not-NULL value
38+
2839
return UMF_RESULT_SUCCESS;
2940
}
3041

0 commit comments

Comments
 (0)