On Tue, Jul 29, 2014 at 9:15 PM, Gavin Lambert <gavinl@compacsort.com> wrote:
There are various techniques for doing this, depending on what that lifetime is -- for example, if it's a single-shot callback then Dominique's suggestion might be reasonable, if you don't mind paying an extra allocation/deallocation each cycle.  If it's a multi-shot callback then it may be better to make a connection-management object that registers/unregisters with the C API and then manage the lifecycle of *that* object appropriately.  There's many methods.

Thank you.  I think you understand what I'm trying to address.

In my case, it's a multi-shot callback.  I don't think I'd need to do a heap allocation/deallocation each cycle, but I'm also not sure that I want to do a heap allocation in the first place.
 
But you have to know what the C API is going to be doing with that pointer, or all bets are off.

In my case, the C API is stashing the value of the pointer in a container, and passing that pointer value as an argument to the registered callback function.  That's it.  The C code doesn't *do* anything with the pointer because it treats it as a void*.