-
Notifications
You must be signed in to change notification settings - Fork 310
so4 #2415
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
Merged
Merged
so4 #2415
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Simplifies freeing compiled ext instances without the need for s dedicated context.
Because it causes issues and they cannot be serialized.
So that it can be mapped and shared between processes.
Hash the address of the pattern instead of the pattern itself
Moved pcre2 pattern code from pattern struct to a hash table inside a context. The reason being the usability of patterns inside printed contexts. pcre2 lib is dynamically loaded and a printed pattern code contains pointers to e.g. malloc(), which caused issues with printed contexts. This way such codes are serialized and deserialized whenever they are needed, which is portable in the same sense as a printed context.
michalvasko
requested changes
Jul 25, 2025
Check for printed context before trying to lock/find/create any inline sm contexts - they do not get printed so they cant be found, it would just crash.
michalvasko
approved these changes
Jul 28, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
libyang SO4 Notable Changes - serialization, context management, and API refinements
API Changes
Context Options upgraded from u16 to u32
Extension Data Callback (
ly_ext_data_clb
)parent
parameter addedlyplg_type_lypath_free
context parameter removedlyplg_type_validate_patterns
context parameter addedPlugin Pointers Replaced by Handles: Pointers to plugins within public lysc_* structs have been replaced by opaque handles
plugin_ref
New APIs
Printed Context Support:
ly_ctx_compiled_size
: Returns the size of a compiled context.ly_ctx_compiled_print
: Serializes (prints) a compiled context.ly_ctx_new_printed
: Deserializes (creates) a new context from a printed representation.ly_ctx_is_printed
: Checks if a context was created from a printed representation.Context Management:
ly_ctx_free_parsed
: Allows explicit freeing of parsed modules within a context.Plugin Information Retrieval:
lysc_get_type_plugin
: Retrieves a type plugin using its handle from publiclysc_*
structs.lysc_get_ext_plugin
: Retrieves an extension plugin using its handle from publiclysc_*
structs.(Internal alternatives:
LYSC_GET_TYPE_PLG
andLYSC_GET_EXT_PLG
)Schema Mount Contexts Serialization Helpers:
lyplg_ext_schema_mount_create_shared_context
: Creates a shared context before serialization of schema mount contexts.lyplg_ext_schema_mount_destroy_shared_contexts
: Destroys shared contexts after deserialization.lyplg_ext_schema_mount_destroy_inline_contexts
: Destroys inline contexts.Type Plugin Value Printing:
lyplg_type_print_val
: Converts a canonical value to a specific format using a type plugin.Data Parsing:
lyd_parse_op
: New parse options parameter added.lyd_parse_ext_op
: New parse options parameter added.Other Changes:
Printed (Serializable/Deserializable) Context Support
New Context Options:
LY_CTX_LYB_HASHES
: Generates hashes for all schema nodesLY_CTX_STATIC_PLUGINS_ONLY
: Restricts context to only use static/global plugins, disallowing user-defined type/extension plugins.Context Modules Set Renamed from
list
tomodules
Distinct Dictionaries for Schema and Data: Schema and data dictionaries are now separate per context => string pointers from data and schema dictionaries can no longer be directly compared.
lysdict_*
functions are now internal and operate on the schema dictionary.lydict_*
functions are public API and operate on the data dictionary.Private and Shared Runtime Data of Each context:
Private Data: Context-specific and thread-specific. Currently, only errors are stored here.
Shared Data: Context-specific but reference-counted, allowing sharing between printed contexts created from the same memory address. Data dictionary, patterns, etc., requires synchronization when accessed.
Lazy Pattern Compilation: Patterns are now stored in a context's hashtable instead of
lysc_pattern
and can be compiled lazily only when neededCanonical Default Values: Default values are now stored in their canonical form.
Testing Improvements: