-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mcache: allow use of arbitrary sizes for malloc-style interface
This modifies the mcache to allow using a malloc/free-style interface (where the allocation size is not specified on a free()) when allocation sizes exceed the largest objcache size. Such use would previously result in an error when attempting to free such large allocations. To accomplish this, the mcache now maintains a mapping of large allocation addresses to their corresponding sizes. When a deallocate with an unspecified (-1ull) size occurs, a table lookup/removal is made to check if the address corresponds to such a "fallback" allocation and, if so, recover the allocation size. The cost of using this fallback table is an insertion when making a fallback (large) allocation and a table lookup/removal when deallocating a fallback allocation of a known size, or on any deallocation (free) of an unknown size. This should not impact the vast majority of mcache uses, for which 1) the allocation size falls within the domain of the contained objcaches and 2) the size parameter is valid on deallocation.
- Loading branch information
Showing
1 changed file
with
71 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters