I need help, about c++ pointer

Поиск
Список
Период
Сортировка
От Quan Zongliang
Тема I need help, about c++ pointer
Дата
Msg-id 20090715205540.75FE.4125B4E5@gmail.com
обсуждение исходный текст
Ответы Re: I need help, about c++ pointer  (Guillaume Lelarge <guillaume@lelarge.info>)
Список pgadmin-support
Hi, all

I ceate some pointers with:
   SQLWCHAR** stmtlabels = m_srcodbc->GetResultColLabels();   m_curstmtlabels = new SQLWCHAR*[m_curstmtcolsnum];   for
(colidx=0;colidx<m_curstmtcolsnum; colidx++)       if (stmtlabels[colidx])       {           m_curstmtlabels[colidx] =
newSQLWCHAR[wcslen(stmtlabels[colidx])+1];           wcscpy(m_curstmtlabels[colidx], stmtlabels[colidx]);       }
else          m_curstmtlabels[colidx] = NULL;
 

delete them with:
   if (m_curstmtlabels)   {       SQLSMALLINT colidx;       for (colidx=0; colidx<m_curstmtcolsnum; colidx++)
if(m_curstmtlabels[colidx])               delete[] m_curstmtlabels;   }
 

When delete pointers, the first loop is ok.
But the sencond loop get a crash.
It seems the first loop delete second array too.
How to correct it?

BTW:
wcscpy, wcscmp, wcslen ... functions can be supported by all platforms?

Regards.

-----------------------------------------------
Quan Zongliang
quanzongliang@gmail.com



В списке pgadmin-support по дате отправления:

Предыдущее
От: Robert Shusteric
Дата:
Сообщение: forgot my password
Следующее
От: Guillaume Lelarge
Дата:
Сообщение: Re: Ubuntu