Add re-entrancy support / multiple instances #9
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.
This PR adds re-entrancy and support for creating multiple instances.
The only limitation is that the instances must have the same TF_Config, i.e. the same field sizes and checksum type. This shouldn't normally be a problem.
TF_Init()
now allocates the instance structure. UseTF_InitStatic()
if you want to allocate it manually.The
tf
struct has two user fields,userdata
andusertag
(void* and uint32_t, respectively). Set those to whatever you like after calling TF_Init() - those can then be checked in any listener or callback (e.g.TF_ClaimTx()
orTF_WriteImpl()
to distinguish the instances..userdata
can be a pointer to some custom user structure.All demos have been updated to work with this new version.