Remove -1 pointers #5037

Open
IntelOrca opened this Issue Jan 10, 2017 · 5 comments

Projects

None yet

3 participants

@IntelOrca
Contributor

RCT2 used the value -1 instead of 0 for a lot of pointers to mean uninitialised. The most common being object entries. We now have a mixture which isn't good, we need to search and destroy all these -1s and use nullptr.

@IntelOrca IntelOrca added the refactor label Jan 10, 2017
@janisozaur
Member

👍 👍 👍 👍 👍

This was so painful when doing 64 bit build.

@janisozaur
Member

Actually, this confuses me a little.

One universal truth about hardware is that it can compare against 0 more efficiently than against anything else. How come -1 was chosen as the invalid value in a handwritten assembly?

@IntelOrca
Contributor

Ask Chris, he even used it for his own malloc function

@Gymnasiast
Member

Perhaps because 0 is a valid value in a lot of places (indices, etc.). I think CS didn't want to make it harder for himself than necessary.

@IntelOrca
Contributor

One universal truth about hardware is that it can compare against 0 more efficiently than against anything else.

Maybe back in the day pre-RCT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment