-
Notifications
You must be signed in to change notification settings - Fork 923
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
Clang identifies the potential to save some memory by reodering the components inside struct UT_hash_table #118
Comments
Changing the layout of that struct would break ABI compatibility (e.g. if someone were fwriting a hash node to disk, or passing a pointer to a hash node across an ABI boundary), so we'd have to be careful if we did this at all. I'd want to at least keep the old layout accessible via I'm inclined to say this is a "Won't Fix" unless someone is proposing a specific patch. |
I understand, and I have created such a patch, but I'm having trouble building
|
Nevermind, I got it to work (you might want to document in the comments in the hashscan.c file that The patch is here (I can create a pull request if you like) and the suite seems to work:
(Function is |
(I also moved |
I'd prefer such a pull request. Saving memory is more relevant for my application than ABI compatibility. |
Building an application using uthash with Clang 3.8 and
-Wpadded
yields the following diagnostic:This is because it is a pointer value but it is located after a number of smaller variables whose total alignment does not equal that of the pointer.
Rearranging the structure, from:
To:
Reduces its size from 64 bytes:
To 56 bytes:
... and eliminates the diagnostic, making uthash build cleaner under common warnings, while saving a small amount of memory.
For more information, see here.
The text was updated successfully, but these errors were encountered: