-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Remove null check from heap::deallocate #14395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
FWIW, |
@nick29581: It seems that @luqmana landed the non-null pointer optimization for slices so this shouldn't be required anymore. Can it be closed? |
This ended up landing as part of the initial implementation, but I don't think it is actually accomplishing anything. |
The pointer in the slice must not be null, because enum representations make that assumption. The `exchange_malloc` function returns a non-null sentinel for the zero size case, and it must not be passed to the `exchange_free` lang item. Since the length is always equal to the true capacity, a branch on the length is enough for most types. Slices of zero size types are statically special cased to never attempt deallocation. This is the same implementation as `Vec<T>`. Closes #14395
Closes rust-lang#10074 changelog: [`redundant_clone`]: fix FP on enum cast
I added this to get DST landed. For
~[T]
types I use a{ptr, len}
fat pointer. If the vector is empy I use null for the pointer, so when this deallocates via drop glue jemalloc segfaults. It should be fairly easy to do a zero sized allocation or something and use that value and then we can remove the null check. That also allows us to use the Option to non-null pointer optimisation. For now I just want to get this branch landed though.cc @thestinger, @alexcrichton
The text was updated successfully, but these errors were encountered: