Salut, ai dreptate.<br>In timp ce scoteam cod, am observat urmatoarea chestie :<br>Daca rulez codul asta :<br><br>int main()<br>{<br> <br> cout << "\n> ";<br> string line;<br> getline(cin, line);
<br> <br> command_t* root = NULL;<br> parse_line(line.c_str(), &root);<br><br> free_parse_memory();<br><br> exit(0);<br><br>}<br><br>Da outputul asta :<br><br>==2981== Memcheck, a memory error detector.
<br>==2981== Copyright (C) 2002-2006, and GNU GPL'd, by Julian Seward et al.<br>==2981== Using LibVEX rev 1606, a library for dynamic binary translation.<br>==2981== Copyright (C) 2004-2006, and GNU GPL'd, by OpenWorks LLP.
<br>==2981== Using valgrind-3.2.0-Debian, a dynamic binary instrumentation framework.<br>==2981== Copyright (C) 2000-2006, and GNU GPL'd, by Julian Seward et al.<br>==2981== For more details, rerun with: -v<br>==2981==
<br>==2981== My PID = 2981, parent PID = 2259. Prog and args are:<br>==2981== ./tema1<br>==2981== <br>--2981-- DWARF2 CFI reader: unhandled CFI instruction 0:50<br>--2981-- DWARF2 CFI reader: unhandled CFI instruction 0:50
<br>==2981== <br>==2981== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 17 from 1)<br>==2981== malloc/free: in use at exit: 17 bytes in 1 blocks.<br>==2981== malloc/free: 12 allocs, 11 frees, 209 bytes allocated.<br>
==2981== For counts of detected errors, rerun with: -v<br>==2981== searching for pointers to 1 not-freed blocks.<br>==2981== checked 108,104 bytes.<br>==2981== <br>==2981== 17 bytes in 1 blocks are possibly lost in loss record 1 of 1
<br>==2981== at 0x401B8C7: operator new(unsigned) (vg_replace_malloc.c:163)<br>==2981== by 0x40B0C6A: std::string::_Rep::_S_create(unsigned, unsigned, std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.8)
<br>==2981== by 0x40B1BE9: std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned) (in /usr/lib/libstdc++.so.6.0.8)<br>==2981== by 0x40B35E7: std::string::reserve(unsigned) (in /usr/lib/libstdc++.so.6.0.8)
<br>==2981== by 0x4089126: std::basic_istream<char, std::char_traits<char> >& std::getline<char, std::char_traits<char>, std::allocator<char> >(std::basic_istream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, char) (in /usr/lib/libstdc++.so.6.0.8)
<br>==2981== by 0x40A2178: std::basic_istream<char, std::char_traits<char> >& std::getline<char, std::char_traits<char>, std::allocator<char> >(std::basic_istream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&) (in /usr/lib/libstdc++.so.6.0.8)
<br>==2981== by 0x80493E9: main (tema1.cpp:875)<br>==2981== <br>==2981== LEAK SUMMARY:<br>==2981== definitely lost: 0 bytes in 0 blocks.<br>==2981== possibly lost: 17 bytes in 1 blocks.<br>==2981== still reachable: 0 bytes in 0 blocks.
<br>==2981== suppressed: 0 bytes in 0 blocks.<br><br><br>Daca rulez codul asta (diferenta este ca in loc sa dau "exit(0)" dau "return 0" ):<br><br>int main()<br>{<br> <br> cout << "\n> ";
<br> string line;<br> getline(cin, line);<br> <br> command_t* root = NULL;<br> parse_line(line.c_str(), &root);<br><br> free_parse_memory();<br> <br> return 0;<br>}<br><br>atunci valgrind spune ca totul e ok - "no memory leaks possible".
<br>