Large alloc fix (#178)

* Improved malloc style tests

Added comprehensive testing of realloc, and other minor improvements
to reporting errors.

* Fix realloc resizing for large sizeclasses.

The rounding by sizeclass was incorrect for large allocation.  This fixes
that.

* Ensure alloc_size is committed

There is an awkward interaction between alloc_size and
committing only what is requested.  If the user assumes
everything up to alloc_size is available, then we need to
either store the more precise size for alloc_size to return
or commit the whole 2^n range, so that alloc_size stays simple.

This changes to just make the whole range committed.
In the future, we might want to store a more precise size, so
that the allocation can be sized more precisely.

* Reduce size of objects.
This commit is contained in:
Matthew Parkinson
2020-05-07 06:31:37 +01:00
committed by GitHub
parent 79ca9bdd9d
commit c899ee7ab2
6 changed files with 66 additions and 12 deletions

View File

@@ -86,7 +86,7 @@ extern "C"
#endif
size_t sz = Alloc::alloc_size(ptr);
// Keep the current allocation if the given size is in the same sizeclass.
if (sz == sizeclass_to_size(size_to_sizeclass(size)))
if (sz == round_size(size))
return ptr;
void* p = SNMALLOC_NAME_MANGLE(malloc)(size);