-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
Add a "private" field to struct cmark_node #287
Comments
Can you say a bit about why this would be useful/how it would be used? |
The biggest problem for language bindings is memory management of the node tree. The tree must only be freed if there are no more references to any of its nodes. The problematic case is when there are no more references to the root node but still some references to child nodes. So every node must somehow keep a reference to the object representing the root node or its parent node. If a pointer to the target language object is stored in the private field, this object can be easily looked up given a only cmark_node. Because the target language only has to store pointers to cmark_nodes, this can simplify things especially for languages where its hard to store additional data (for example in a Perl A private field can also be useful for C users to store arbitrary stuff associated with a node. Thinking more about it, I don't think using a union with an additional integer type is that useful. So I change my initial proposal to something like:
|
Thanks for the explanation. I have no objections to adding +++ Nick Wellnhofer [Jan 19 15 05:20 ]:
|
For bindings from other languages to libcmark, it would be useful to add a "private" field to
struct cmark_node
that makes it possible to store a pointer to (or other identifier of) the object that represents the node in the other language. Something like:The text was updated successfully, but these errors were encountered: