#Passing state to formatter
7 messages ยท Page 1 of 1 (latest)
No reserved section?
I find a lot of structs have reserved bytes you can stuff all sorts of stuff into ๐
You could keep an external mapping or some kind of limited global variable somewhere, though that definitely has some complications associated with it.
Right, however you do seem to be trying to do something that's already really wonky so I suspect you'll either have to change what you want to do, or do something that's hacky to make it work.
Can you have a wrapper object on the stack that doesn't copy the original struct, just contains a little more metadata, like the symbol table address or the like, and pass that around?
Yeah ๐ I'd be surprised if there was a cheaper way to do than than to use something that's not a formatter but gets the job done.
Or, if you're lucky enough with how your code works, you can have explicit threadlocal state management where the external API sets a threadlocal with, say, a pointer to the relevant symbol table at the entry point of a function and then sets it back right before it returns. If there's only one of these on any given thread at any given time, that might not be too expensive. Really depends on the semantics you are going for.