Can any body suggest me how can I free the dynamic memory in the given code
int fun(CString qry, CStringList *List,int n)
{
using namespace std;
string sqlStmt = qry;
int i;
this->stmt = this->conn->createStatement (sqlStmt);
ResultSet *rset = this->stmt->executeQuery ();
string **oraRecordsStr=NULL;
try
{
while (rset->next())
{
if(oraRecordsStr == NULL)
{
oraRecordsStr=new string*[n];
for(i=0;i<n;i++)
oraRecordsStr[i] = new string;
}
for(i=0;i<n;i++)
{
*oraRecordsStr[i]= rset->getString (i+1);
List->AddTail(oraRecordsStr[i]->c_str());
}
for(i=0;i<n;i++)
oraRecordsStr[i] = NULL;
oraRecordsStr=NULL;
}
}
}
i tried
for(i=0;i<n;i++)
delete []oraRecordsStr[i];
delete []oraRecordsStr;
but it didn't work
Thanks in advance