Skip to content

Commit

Permalink
jemalloc: Avoid adding bounds unnecessarily
Browse files Browse the repository at this point in the history
The memory returned by je_allocm() and je_rallocm() is allocated using
je_mallocx() and je_(x|r)allocx(), respectively, and those functions apply
bounds to their return values by virtue of being implemented using
imalloc().

This makes it easier to make jemalloc bound pointers to the usable size
instead of the allocation size.
  • Loading branch information
markjdb committed Jul 10, 2024
1 parent 5a078fe commit 393d4f3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contrib/jemalloc/src/jemalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3848,7 +3848,7 @@ je_allocm(void **ptr, size_t *rsize, size_t size, int flags) {
if (rsize != NULL) {
*rsize = isalloc(tsdn_fetch(), p);
}
*ptr = BOUND_PTR(p, size);
*ptr = p;
return ALLOCM_SUCCESS;
}

Expand All @@ -3873,7 +3873,7 @@ je_rallocm(void **ptr, size_t *rsize, size_t size, size_t extra, int flags) {
} else {
void *p = je_rallocx(*ptr, size+extra, flags);
if (p != NULL) {
*ptr = BOUND_PTR(p, size+extra);
*ptr = p;
ret = ALLOCM_SUCCESS;
} else {
ret = ALLOCM_ERR_OOM;
Expand Down

0 comments on commit 393d4f3

Please sign in to comment.