Good day!
I have a C function that would open a database. But when i ran it in
valgrind, it gave me the following leak:
==7230== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 16 from 1)
==7230== malloc/free: in use at exit: 272 bytes in 2 blocks.
==7230== malloc/free: 289 allocs, 287 frees, 42,704 bytes allocated.
==7230== For counts of detected errors, rerun with: -v
==7230== searching for pointers to 2 not-freed blocks.
==7230== checked 21,050,692 bytes.
==7230==
==7230== 272 bytes in 2 blocks are possibly lost in loss record 1 of 1
==7230== at 0x40056BF: calloc (vg_replace_malloc.c:279)
==7230== by 0x35771A: _dl_allocate_tls (in /lib/ld-2.3.4.so)
==7230== by 0x5B591E: pthread_create@@GLIBC_2.1 (in
/lib/tls/libpthread-2.3.4.so)
==7230== by 0x4030E52: findLockInfo (os_unix.c:504)
==7230== by 0x4031ABD: unixOpen (os_unix.c:2268)
==7230== by 0x403080C: sqlite3OsOpen (os.c:134)
==7230== by 0x40330A7: sqlite3PagerOpen (pager.c:2160)
==7230== by 0x401707E: sqlite3BtreeOpen (btree.c:1226)
==7230== by 0x402F03C: sqlite3BtreeFactory (main.c:767)
==7230== by 0x402F68D: openDatabase (main.c:1016)
==7230== by 0x8049482: OpenDB (in
/home/sample/testing/sqlite3/v0.08/driver)
==7230== by 0x80489F5: main (DbDriver.c:60)
==7230==
==7230== LEAK SUMMARY:
==7230== definitely lost: 0 bytes in 0 blocks.
==7230== possibly lost: 272 bytes in 2 blocks.
==7230== still reachable: 0 bytes in 0 blocks.
==7230== suppressed: 0 bytes in 0 blocks.
==7230== Reachable blocks (those to which a pointer was found) are not
shown.
==7230== To see them, rerun with: --show-reachable=yes
In DbDriver.c, my line number 60 is:
[60] if( ( res_i = OpenDB( "this.db" ) ) == SQLITE_OK )
[61] {
...
}
and my OpenDB looks like this:
int OpenDB( char *dbName_cp )
{
int retVal_i = CDBM_FAIL; /*< error code */
/* checks if the database name is not equal to NULL */
if( dbName_cp != NULL )
{
/* opens the database */
retVal_i = sqlite3_open( dbName_cp, &GDBM_Db_p );
}
return( retVal_i );
}
Is this a valid memory leak?..where did i go wrong in my codes?..
Thank you and God bless!
--
View this message in context:
http://www.nabble.com/memory-leak-on-sqlite3_open-tp14629415p14629415.html
Sent from the SQLite mailing list archive at Nabble.com.
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------