You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All of the functions that operate on files, such as mpack_reader_init_filename store the file handle in the custom context. This means that the context can't be set by the user to anything else, like for use in error handlers.
I feel like either the file IO helpers should use their own, separate context, or it should be documented that calling mpack_reader_set_context and similar is not allowed when file IO is used.
The text was updated successfully, but these errors were encountered:
The only purpose of the context is for callbacks like fill, flush, etc. mpack_reader_init_filename() installs its own fill and destroy callbacks so it uses the context. The documentation of mpack_reader_set_context() does indeed say that the context is for callbacks.
I suppose I could clarify the documentation of functions like mpack_reader_init_filename() to say that they install callbacks and use the context so you can't use your own callbacks and context with them.
Is the problem that you are trying to use an error callback with your own context? It occurred to me that the reader doesn't install an error callback; that's the only reason I can think of to want to use your own context. In that case you're probably right, and I should make these functions use their own context.
As a workaround you could wrap the reader in a struct with your context. You could then cast a pointer from the reader to the containing struct.
Yes, my intention was to have error callbacks with my own context while reading out of a file. I suppose you're right that there isn't much of a need to set your own context otherwise, so apologies for overgeneralizing the problem.
All of the functions that operate on files, such as
mpack_reader_init_filename
store the file handle in the custom context. This means that the context can't be set by the user to anything else, like for use in error handlers.I feel like either the file IO helpers should use their own, separate context, or it should be documented that calling
mpack_reader_set_context
and similar is not allowed when file IO is used.The text was updated successfully, but these errors were encountered: