On Jun 26, 2009, at 3:49 PM, Greg Morehead wrote:

> The extremely simple app below leaks.  What am I doing wrong??   
> Please help.

How do you know it is leaking memory?  How are you measuring?

>
>
> #include <cstdlib>
> #include <iostream>
> #include "stdio.h"
> #include "sqlite3.h"
> #include <unistd.h>
>
> #define TFQ_SQL_DB_NAME "/powerblock/datalog/TFQ-test.db"
> #define _TABLE_NAME "sqltest"
>
> int main(int argc, char *argv[])
> {
>       char sql[1024];
>       char * errmsg;
>       sqlite3* db_;
>       int flags = SQLITE_OPEN_FULLMUTEX | SQLITE_OPEN_READWRITE |  
> SQLITE_OPEN_CREATE;
>       
>       if (sqlite3_open_v2(TFQ_SQL_DB_NAME
>                                               , &db_
>                                               , flags
>                                               , NULL) != SQLITE_OK)   {
>               return EXIT_FAILURE;
>       }
>       
>       sprintf(sql,
>                       "CREATE TABLE %s_info (col_idx, col_name, data_type, 
> meta_type,  
> description, grouping); "
>                       , _TABLE_NAME);
>
>       int retval = sqlite3_exec(db_, sql, 0, 0, &errmsg);
>       int idx = 1;
>       while(retval==SQLITE_OK)
>       {
>               sprintf(sql,
>                               "INSERT INTO %s_info VALUES(%d, \"rowid\", 
> \"INTEGER\", \"%s\",  
> \"Unique Row ID\", \"_SQL\");"
>                               , _TABLE_NAME, idx++, "INTEGER" );
>               
>               retval = sqlite3_exec(db_, sql, 0, 0, &errmsg);         
>               
>               if(retval != SQLITE_OK) {
>                       printf("Recieved an sqlite failure. : Failed msg: %s", 
> errmsg);
>                       sqlite3_free(errmsg);
>               }
>               else
>                       printf("Successfully inserted row idx %d\r\n", idx);
>                       
>               usleep(50000);
>       }
>       return EXIT_SUCCESS;
> }
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

D. Richard Hipp
d...@hwaci.com



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to