From: Nicholas N. <nj...@ca...> - 2003-04-10 18:33:28
|
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]; > } > } > 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. N |