mirror of
https://github.com/jemalloc/jemalloc
synced 2026-06-08 15:01:07 +00:00
Use offsetof() when sizing dynamic structures.
Base dynamic structure size on offsetof(), rather than subtracting the size of the dynamic structure member. Results could differ on systems with strict data structure alignment requirements.
This commit is contained in:
@@ -101,8 +101,8 @@ arenas_extend(unsigned ind)
|
||||
arena_t *ret;
|
||||
|
||||
/* Allocate enough space for trailing bins. */
|
||||
ret = (arena_t *)base_alloc(sizeof(arena_t)
|
||||
+ (sizeof(arena_bin_t) * (nbins - 1)));
|
||||
ret = (arena_t *)base_alloc(offsetof(arena_t, bins)
|
||||
+ (sizeof(arena_bin_t) * nbins));
|
||||
if (ret != NULL && arena_new(ret, ind) == false) {
|
||||
arenas[ind] = ret;
|
||||
return (ret);
|
||||
|
||||
Reference in New Issue
Block a user