|
From: | Simon Goldschmidt |
Subject: | Re: [lwip-devel] Memory leak for timeouts |
Date: | Tue, 6 Nov 2007 18:18:18 +0100 |
Am 06.11.2007 um 18:02 schrieb Marc CHALAND:
2007/11/6, Goldschmidt Simon <address@hidden>:As you malloc the struct yourself (in your port) you have to provide thethread-exit function yourself (or in your port), which is not a thing every port (or even the core) needs.OK, you confirm that we should implement a thread exit function which frees allocated memory. As this memory is allocated into sys_arch.c (sys_timeouts), I thought it is better to put the free into the same file. As a consequence I thought it should be declared into sys.h in a same maner as sys_thread_new. What do you think about it ?
The memory isn't allocated 'into sys_arch.c'. Many ports use a static array of tasks that can be activated. This array includes a struct sys_timeout per thread. So when a thread is not running any more, this struct can be reused for the next thread created.
Effectively, you control how the struct is created. If you need a thread exit function that deallocates something, you may indeed need a thread exit function. But this is not something most port needs, so not something I would include in sys_arch.c or sys.h!
For example, implement your own thread creation wrapper that allocates the struct per thread, the call the actual thread function and deallocate when the function returns (which means the thread ends).
Simon
[Prev in Thread] | Current Thread | [Next in Thread] |