Record* MyClass::get_record (int id)
{
Record* rec = new Record();
Record* compressed_rec;
/* ... code that gets compressed_rec into memory ... */
compressed_rec->decompress(rec);
return rec;
}
这个函数总是这样使用:
Record* rec = my_class_instance.get_record (id);
show_contents_of(rec);
delete rec;
valgrind
说我在第一行 ( Record* rec = new Record();
) 上泄漏了内存。为什么?