Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Redundant union members in IoObject_struct.h #197

Open
kmag opened this Issue · 5 comments

4 participants

@kmag

Currently in head in https://github.com/stevedekorte/io/blob/master/libs/iovm/source/IoObject_struct.h

IoObjectData contains:

union
{
union
{
void *ptr;
void *ptr2;
} pointers;
double d;
uint32_t ui32;
} data; // 8 bytes (9+8 = 17)

ptr and ptr2 have the same type and occupy the same space. The names seem to imply the intention was to use them as a cons cell, or at least be able to use both ptr and ptr simultaneously.

On #io today, jer had a look and it doesn't appear that IoObject_dataPointer2 is used anywhere. ptr2 should probably be removed along with pointers, and ptr placed directly in data. There's no performance or space savings, but it gets rid of a potential source of subtle bugs.

@kmag

On a side note, the comments counting the bytes in the struct look non-sensical.

@jeremytregunna

I agree with this statement entirely. And can confirm that ptr2 (and the associated macros IoObject_dataPointer2 and IoObject_setDataPointer2) are not used anywhere in the codebase.

If there are no objections, I'll pull these out and submit the match.

@stevedekorte
Owner

Sounds good - don't recall what that was about. :)

@jeremytregunna

I've submitted the pull request (#199).

@gatesphere

Nice catch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.