Skip to content
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

Tightly pack the cJSON struct #313

Closed
wants to merge 1 commit into from
Closed

Conversation

marcomagdy
Copy link

Running pahole(https://linux.die.net/man/1/pahole) flags cJSON as a
packable struct on x86-64.

This patch moves the members of type 'int' next to each other and plugs
the two 4-bytes holes. This reduces the struct size from 64-bytes to
56-bytes.
see https://godbolt.org/z/gUr5ue

I understand that this breaks the ABI. So, probably a version bump is due.

Running pahole(https://linux.die.net/man/1/pahole) flags cJSON as a
packable struct on x86-64.

This patch moves the members of type 'int' next to each other and plugs
the two 4-bytes holes. This reduces the struct size from 64-bytes to
56-bytes.
see https://godbolt.org/z/gUr5ue
@FSMaxB
Copy link
Collaborator

FSMaxB commented Nov 27, 2018

As you already mentioned, this breaks the ABI. See the issue where I'm tracking ideas of how the struct could look like in the future: #63

@FSMaxB FSMaxB closed this Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants