Another pointer error.

ponters are created by:
    int tablecount = 0;
    SQLWCHAR **tabledata, ***tablelist;

    while (true)
    {
        sqlrc = SQLFetch(tableshstmt);
        if (sqlrc != SQL_SUCCESS && sqlrc != SQL_SUCCESS_WITH_INFO)
            break;

        if (m_dsnmaxcatnamelen)
        {
            SQLGetData(tableshstmt, 1, SQL_C_WCHAR, catname, 
sizeof(SQLWCHAR)*m_dsnmaxcatnamelen, NULL);
            catnameptr = new SQLWCHAR[wcslen(catname)+1];
            wcscpy(catnameptr, catname);
        }
        else
            catnameptr = NULL;

        if (m_dsnmaxschemnamelen)
        {
            SQLGetData(tableshstmt, 2, SQL_C_WCHAR, schemname, 
sizeof(SQLWCHAR)*m_dsnmaxschemnamelen, NULL);
            schemnameptr = new SQLWCHAR[wcslen(schemname)+1];
            wcscpy(schemnameptr, schemname);
        }
        else
            schemnameptr = NULL;

        SQLGetData(tableshstmt, 3, SQL_C_WCHAR, tablename, 
sizeof(SQLWCHAR)*m_dsnmaxtablenamelen, NULL);
        tablenameptr = new SQLWCHAR[wcslen(tablename)+1];
        wcscpy(tablenameptr, tablename);

        tabledata = new SQLWCHAR *[3];
        tabledata[0] = catnameptr;
        tabledata[1] = schemnameptr;
        tabledata[2] = tablenameptr;

        tablelist = m_tablelist;
        m_tablelist = new SQLWCHAR **[tablecount+1];
        if (tablecount)
            memcpy(m_tablelist, tablelist, sizeof(SQLWCHAR**)*tablecount);
        m_tablelist[tablecount] = tabledata;
        if (tablelist)
            delete[] tablelist;

        tablecount++;
    }

    tablelist = m_tablelist;
    m_tablelist = new SQLWCHAR **[tablecount+1];
    if (tablecount)
        memcpy(m_tablelist, tablelist, sizeof(SQLWCHAR**)*tablecount);
    m_tablelist[tablecount] = NULL;
    if (tablelist)
        delete[] tablelist;
(m_tablelist is defined in header file: SQLWCHAR ***m_tablelist)
Cleared by:
    SQLWCHAR ***tablelist;
    for (tablelist=m_tablelist; *tablelist; tablelist++)
    {
        if ((*tablelist)[0])
            delete[] (*tablelist)[0];
        if ((*tablelist)[1])
            delete[] (*tablelist)[1];
        delete[] (*tablelist)[2];

        delete[] (*tablelist);
    }

    delete[] m_tablelist;

When second lood try to delete pointer,
system said that memory seems has been deleted.

My pgsql test db has 21 tables,
when connect to it with ODBC I always get this error.
But a excel doc has 3 sheets(will be considered as 3 tables in ODBC driver)
no error occur.

-----------------------------------------------
Quan Zongliang
quanzongli...@gmail.com


-- 
Sent via pgadmin-support mailing list (pgadmin-support@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-support

Reply via email to