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

Expose patricia_search_all on SubnetTree #37

Merged
merged 2 commits into from
Jun 24, 2024
Merged

Conversation

ikbenale
Copy link
Contributor

@ikbenale ikbenale commented May 8, 2024

Note: there are some unrelated changes on SubnetTree_wrap.cc that appear when I make the project. First I assumed it was because I was using a newer version of SWIG, but I downloaded and compiled the one used in the file comments, 3.0.12, and I still got those discrepancies. If it's more convenient, I can manually edit those changes to omit unwanted lines.

@bbannier
Copy link
Member

bbannier commented May 9, 2024

Note: there are some unrelated changes on SubnetTree_wrap.cc that appear when I make the project.

Yeah, I saw that to, there must have been something else about these files. The commit making the last update talks about keeping changes minimal, maybe there was some manual editing involved then.

For fixing a new runtime failure with e.g., python-3.11.9 we have merged a fix #38 which updates the generated files so you should see a smaller diff now. That PR also brings CI up to date (e.g., python-3.7 is not available anymore in macos CI). If you rebase your PR on the lasted HEAD you'll get these changes.

@ikbenale
Copy link
Contributor Author

ikbenale commented May 9, 2024

@bbannier rebased and now my diff looks clean 👍. I pushed the new version.

SubnetTree.cc Outdated Show resolved Hide resolved
testing/pysubnettree/search-all.test Show resolved Hide resolved
@awelzel
Copy link
Contributor

awelzel commented Jun 17, 2024

First I assumed it was because I was using a newer version of SWIG, but I downloaded and compiled the one used in the file comments, 3.0.12, and I still got those discrepancies. If it's more convenient, I can manually edit those changes to omit unwanted lines.

Yeah, I saw that to, there must have been something else about these files. The commit making the last update talks about keeping changes minimal, maybe there was some manual editing involved then.

That was me: I've used swig 3.0.12 from Debian which carries a number of patches that change the generated output and that's how these got introduced. I confirm that by using an unaltered and pristine swig 3.0.12, the code isn't changed.

@awelzel awelzel merged commit ebca8ed into zeek:master Jun 24, 2024
@awelzel
Copy link
Contributor

awelzel commented Jun 24, 2024

@ikbenale - I've merged after adding a free() for the returned outlist to plug a memory leak.

Thanks for your contribution!

@ikbenale
Copy link
Contributor Author

@awelzel awesome, thanks!

I've merged after adding a free()

Out of curiosity, where did you add this? I don't see that change on master 🤔

@awelzel
Copy link
Contributor

awelzel commented Jun 24, 2024

The change is in the merge commit. This part look slightly different now:

pysubnettree/SubnetTree.cc

Lines 350 to 360 in ebca8ed

int result = patricia_search_all(tree, sn, &outlist, &n);
Deref_Prefix(sn);
PyObject* list = PyList_New(n);
for (int i = 0; i < n; i++) {
PyObject* data = (PyObject*)outlist[i]->data;
Py_INCREF(data);
PyList_SetItem(list, i, data);
}
free(outlist);

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.

3 participants