Hi,
this is not meant as an intensive review on memory allocations in the PCU code. While browsing the code of the ready-to-send method to select the next payload I noticed the code below:
RlcMacDownlink_t * mac_control_block = (RlcMacDownlink_t *)malloc(sizeof(RlcMacDownlink_t)); LOGP(DRLCMAC, LOGL_DEBUG, "+++++++++++++++++++++++++ TX : Packet Paging Request +++++++++++++++++++++++++\n"); decode_gsm_rlcmac_downlink(pag_vec, mac_control_block); LOGPC(DCSN1, LOGL_NOTICE, "\n"); LOGP(DRLCMAC, LOGL_DEBUG, "------------------------- TX : Packet Paging Request -------------------------\n"); bitvec_free(pag_vec);
This and other all other places really should use talloc to make finding memory leaks more easy (e.g. by printing the leak report), the second part is that we appear to leak this on every paging message sent by the PCU and the third is actually a question. Should we use a GCC extension that helps dealing with local variables? GCC can call a cleanup function on exit of the scope, an example can be seen here[1] nad this[2] is the description of the feature.
holger
[1] https://mail.gnome.org/archives/gtk-devel-list/2011-November/msg00050.html [2] http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html#Variable-Attribut...
On Tue, Jul 24, 2012 at 11:51 PM, Holger Hans Peter Freyther hfreyther@sysmocom.de wrote:
Should we use a GCC extension that helps dealing with local variables? GCC can call a cleanup function on exit of the scope, an example can be seen here[1] nad this[2] is the description of the feature.
Oh, this looks like "hack your C to be C++", isn't it better to just use C++ then? It has a very clean semantics for this which is supported by _all_ compilers.
On Wed, Jul 25, 2012 at 09:17:03AM +0200, Alexander Chemeris wrote:
Oh, this looks like "hack your C to be C++", isn't it better to just use C++ then? It has a very clean semantics for this which is supported by _all_ compilers.
Hi,
for me the PCU code is C compiled with a C++ compiler. I would more think we will move to using to use a C compiler than using more of C++ features. But yes the 'cleanup' attribute can be easily handled by a "template TallocPtr<T>" class.
holger
osmocom-net-gprs@lists.osmocom.org