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

Remove all stack allocations #235

Merged
merged 1 commit into from
May 16, 2019

Conversation

isaacbrodsky
Copy link
Collaborator

Fixes #233

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 02449fb on isaacbrodsky:remove-stack-alloc into a8212ce on uber:master.

@@ -51,10 +50,12 @@ static void h3Line_assertions(H3Index start, H3Index end) {
"index is a neighbor of the previous index");
if (i > 1) {
t_assert(
!H3_EXPORT(h3IndexesAreNeighbors)(line[i], line[i - 3]),
!H3_EXPORT(h3IndexesAreNeighbors)(line[i], line[i - 2]),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a bugfix in the test? If so, how did it work before?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That must be my bug - I'm guessing that the invalid array access (would be line[-1] on the first access) wasn't throwing an error with stack allocation, and since the assertion is a negative one, it passes on !h3IndexesAreNeighbors(h3Index, trash) - it would only fail if the trash access gave it an H3 index that was a neighbor.

Not sure how I made the mistake in the first place, but good catch!

@@ -64,7 +65,7 @@ static void h3Line_invalid_assertions(H3Index start, H3Index end) {
int sz = H3_EXPORT(h3LineSize)(start, end);
t_assert(sz < 0, "line size marked as invalid");

H3Index* line = {0};
H3Index *line = {0};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand it's due to the linter, but I've never understood the C style to put the star next to the variable name. The type of the variable is a pointer to an H3Index, and you reference the variable with just the text part of the name, so the star seems to be more reasonably associated with that type.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the reasoning for this linter rule is due to how C handles H3Index *a, b; which creates one pointer-to-H3Index and one H3Index.

Copy link
Collaborator

@nrabinowitz nrabinowitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG, thanks!

@@ -51,10 +50,12 @@ static void h3Line_assertions(H3Index start, H3Index end) {
"index is a neighbor of the previous index");
if (i > 1) {
t_assert(
!H3_EXPORT(h3IndexesAreNeighbors)(line[i], line[i - 3]),
!H3_EXPORT(h3IndexesAreNeighbors)(line[i], line[i - 2]),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That must be my bug - I'm guessing that the invalid array access (would be line[-1] on the first access) wasn't throwing an error with stack allocation, and since the assertion is a negative one, it passes on !h3IndexesAreNeighbors(h3Index, trash) - it would only fail if the trash access gave it an H3 index that was a neighbor.

Not sure how I made the mistake in the first place, but good catch!

@isaacbrodsky isaacbrodsky merged commit a6cd31b into uber:master May 16, 2019
@isaacbrodsky isaacbrodsky deleted the remove-stack-alloc branch May 16, 2019 23:23
mrdvt92 pushed a commit to mrdvt92/h3 that referenced this pull request Jun 19, 2022
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.

iOS does not support stack array allocation
4 participants