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

No "forwarding" of memory handler functions to libexpat #85

Open
Sacryn opened this issue Apr 4, 2016 · 5 comments
Open

No "forwarding" of memory handler functions to libexpat #85

Sacryn opened this issue Apr 4, 2016 · 5 comments

Comments

@Sacryn
Copy link

Sacryn commented Apr 4, 2016

When creating the parser context, the memory functions set when creating the xmpp-context is not forwarded to libexpat. This causes libexpat to use regular malloc/realloc/free instead, which is a issue in projects where you must use custom allocators.

I realize problematic to solve, as memory functions are xmpp-context dependent. But maybe implementing a way to set a global memory functions (more or less a configurable default xmpp_mem_t) could solve this (which would then be forwarded to libexpat via calling XML_ParserCreate_MM instead of XML_ParserCreateNS)

@pasis
Copy link
Member

pasis commented Apr 4, 2016

Good catch. The same situation with libxml2 module. I don't see any acceptable solution with current interface neither.

I wouldn't recommend to add a global state to libstrophe. Global allocator would require locking for multi-thread applications for example.

Removing argument userdata allows to pass libstorphe's allocator to expat and libxml2, but this also breaks user allocators that don't use global state.

I will think what we can do in this situation...

@pasis
Copy link
Member

pasis commented Apr 7, 2016

Since I don't see perfect solution I would recommend to remove userdata argument from the libstrophe's API. Users still can implement multi-thread allocators of any complexity and libstrophe's code remains simple and without internal locking.

I made a quick search for openssl custom allocator, but haven't found anything. Anyway playing with crypto library is not a good idea.

Are you interested in preparing the patch? Or I can implement this.

@Sacryn
Copy link
Author

Sacryn commented Apr 8, 2016

Feel free to implement/patch. I'm a bit swamped at the moment otherwise I would be happy to help out.

@pasis
Copy link
Member

pasis commented Apr 8, 2016

No problem, I'll do this at spare time.

@pasis
Copy link
Member

pasis commented Jan 8, 2020

fb327d4 fixes the issue for a single strophe context. Libxml2 module still doesn't override memory functions.

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

No branches or pull requests

2 participants