From: Crispin F. <cr...@th...> - 2003-04-10 20:44:14
|
I just tried the sample code (once I had got it to compile) and it worked fine - as expected. If you can provide a complete program that acts as a test case, then you may have more luck tracking down the problem in your code. Crispin On Thu, 2003-04-10 at 21:28, Xiang Yan wrote: > On Thu, 10 Apr 2003, Xiang Yan wrote: > > > > > My question is, for code below, valgrind will report an error or not on > memory allocated for c1::m_p1? > > > class c1 > > > { > > > ~c1() > > > { > > > delete []m_p1; > > > } > > > void * m_p1; > > > } > > > > > > class c2 > > > { > > > ~c2() { > > > if(m_c1 != NULL) > > > delete []m_c1; > > > } > > > func1() { > > > m_c1 = new c1[10]; > > > for(i = 0; i < 10; i++) { > > > m_c1[i].m_p1 = new char[10]; // reports definitely lost here > > > } > > > } > > > c1 *m_c1; > > > } > > > > > > somewhere else outside above class has following call: > > > c2 *pc2 = new c2(); > > > c2->func1(); > > > delete c2; > > > > You've written an almost-whole program, and you want to know what Valgrind > > says about it? > > > > It looks to me like there won't be any errors, because AFAICT the memory > > is all deallocated correctly. But I suggest you finish and compile the > > program, and run Valgrind on it. > > That's the result of running Valgrind on my code, the line it indicated is > below with definitly lost message: > m_c1[i].m_p1 = new char[10]; // refer to above > (it's multithreaded btw) > > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger > for complex code. Debugging C/C++ programs can leave you feeling lost and > disoriented. TotalView can help you find your way. Available on major UNIX > and Linux platforms. Try it free. www.etnus.com > _______________________________________________ > Valgrind-users mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-users > |