This is a C structure, ordinary old data, so there is no destructor to introduce side effects when it goes beyond. The only consequence of losing the area is that you can no longer see it.
I know your question is C, but many thread implementations solve the problem with something like this:
class Thread { pthread_t handle; static void * start (void * self) { static_cast <Thread *> (self) -> run (); } protected: void run () = 0; public: void start () { pthread_create (&handle, NULL, start, this); } ~ Thread () { pthread_join (&handle, NULL); } };
You can do something similar with C, arg is a pointer to a malloc ed structure that contains a stream handle; frees stream frees upon completion.
source share