Skip to content

Commit 2e74bef

Browse files
authored
Merge pull request #4565 from benmenadue/master
Use malloc instead of posix_memalign for small (<= sizeof(void *)) alignments
2 parents ad59b93 + 90fa8af commit 2e74bef

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

opal/mca/mpool/base/mpool_base_alloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void *mca_mpool_base_alloc(size_t size, opal_info_t *info, const char *hints)
7474

7575
mpool = mca_mpool_base_module_lookup (hints);
7676
if (NULL != mpool) {
77-
mem = mpool->mpool_alloc (mpool, size, 0, 0);
77+
mem = mpool->mpool_alloc (mpool, size, sizeof(void *), 0);
7878
}
7979

8080
if (NULL == mem) {

opal/mca/mpool/base/mpool_base_default.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ static void *mca_mpool_default_alloc (mca_mpool_base_module_t *mpool, size_t siz
3131
#if HAVE_POSIX_MEMALIGN
3232
void *addr = NULL;
3333

34-
(void) posix_memalign (&addr, align, size);
34+
if (align <= sizeof(void *)) {
35+
addr = malloc (size);
36+
} else {
37+
(void) posix_memalign (&addr, align, size);
38+
}
3539
return addr;
3640
#else
3741
void *addr, *ret;

0 commit comments

Comments
 (0)