Issue a warning upon directly accessing an arena's bins

An arena's bins should normally be accessed via the `arena_get_bin`
function, which properly takes into account bin-shards. To ensure that
we don't accidentally commit code which incorrectly accesses the bins
directly, we mark the field with `__attribute__((deprecated))` with an
appropriate warning message, and suppress the warning in the few places
where directly accessing the bins is allowed.
This commit is contained in:
Kevin Svetlitski
2023-08-04 11:43:59 -07:00
committed by Qi Wang
parent 120abd703a
commit 424dd61d57
2 changed files with 18 additions and 6 deletions

View File

@@ -99,7 +99,9 @@ struct arena_s {
* The arena is allocated alongside its bins; really this is a
* dynamically sized array determined by the binshard settings.
*/
bin_t bins[0];
JEMALLOC_WARN_ON_USAGE("Do not use this field directly. "
"Use `arena_get_bin` instead.")
bin_t all_bins[0];
};
#endif /* JEMALLOC_INTERNAL_ARENA_STRUCTS_H */