Remove null check from heap::deallocate

3df80db
Opened by Nick Cameron at 2014-09-11 07:10:53

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

  1. FWIW, Vec uses 1 as *T as the sentinel value for this sort of situation (to ensure that Option<...> still works, since that uses the "non-null" pointer as the discriminant).

    Huon Wilson at 2014-05-24 06:06:24

  2. @nick29581: It seems that @luqmana landed the non-null pointer optimization for slices so this shouldn't be required anymore. Can it be closed?

    Daniel Micay at 2014-07-11 16:20:03

  3. This ended up landing as part of the initial implementation, but I don't think it is actually accomplishing anything.

    Daniel Micay at 2014-09-08 05:51:10