When reading the process of creating MIB tree (net-snmp 5.3.2.pre1), I find
that the process may cause the memory leak, could you give me some suggestions?
setting up the MIB tree firstly, the process of function calling as follows:
-> main()
-> init_agent(()
-> setup_tree()
// at first, register the subtree of ccitt.
//code:
......
netsnmp_register_null(snmp_duplicate_objid(ccitt, 1), 1);
......
-> netsnmp_register_null()
-> netsnmp_register_null_context()
-> netsnmp_register_handler()
-> netsnmp_register_mib()
// malloc the buffer for the ccitt subtree for the first
time
// code:
......
subtree = (netsnmp_subtree *)calloc(1, sizeof(netsnmp_subtree));
......
-> netsnmp_subtree_load()
// I find this function call the register process of ccitte subtree again.
// we are creating the first subtree of ccitt,
// so netsnmp_subtree_find_first() return false.
// code:
................
if (!netsnmp_subtree_find_first(context_name))
{
static int inloop = 0;
// the first time call the netsnmp_subtree_load,
inloop's value is 0;
if (!inloop)
{
inloop = 1;
....
// so we can arrive here to create the subtree of
ccitt again.
netsnmp_register_null_context(snmp_duplicate_objid(ccitt, 1), 1,context_name);
...
inloop = 0;
}
}
....................
-> netsnmp_register_null_context() (call again)
-> netsnmp_register_handler() (call again)
-> netsnmp_register_mib() (call again)
// malloc the buffer for the ccitt subtree the second time
// code :
.........
subtree = (netsnmp_subtree *)calloc(1, sizeof(netsnmp_subtree));
.............
-> continue to register the ccitt subtree ...............
I have found that the proceess registers the subtree created the second time,
and abandons the subtree of created at the first time. I haven't found the free
buffer for the ccitt tree cteated at the first time, Why does it create the
subtree repeatly? Can this cause memory leak?
Thanks in advanced.
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders