私は mysql db からいくつかのデータを要求する単純な C プログラムを書いています。この関数は、シングル スレッド アプリケーションで使用するとメモリ リークを報告しませんが、スレッドでは報告します。
機能はこれです不要なコードを削除しました
BOOL getip(char * ip,int * port,BOOL serie)
{
MYSQL * conn,mysql;
MYSQL_RES * res;
MYSQL_ROW row;
char * server = "someip";
char * user = "root";
char * pass = "root";
char * db = "testdb";
char * query = NULL;
mysql_init(&mysql);
mysql_close(&mysql);
}
> ==30295== HEAP SUMMARY:
> ==30295== in use at exit: 73,872 bytes in 21 blocks
> ==30295== total heap usage: 85 allocs, 64 frees, 119,908 bytes allocated
> ==30295==
> ==30295== 128 bytes in 1 blocks are definitely lost in loss record 2 of 5
> ==30295== at 0x402A629: calloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
> ==30295== by 0x408FB63: my_thread_init (in /usr/lib/i386-linux-gnu/libmysqlclient.so.18.0.0)
> ==30295== by 0x408FE43: my_thread_global_init (in /usr/lib/i386-linux-gnu/libmysqlclient.so.18.0.0)
> ==30295== by 0x408E2D7: my_init (in /usr/lib/i386-linux-gnu/libmysqlclient.so.18.0.0)
> ==30295== by 0x406B3FA: mysql_server_init (in /usr/lib/i386-linux-gnu/libmysqlclient.so.18.0.0)
> ==30295== by 0x406CB28: mysql_init (in /usr/lib/i386-linux-gnu/libmysqlclient.so.18.0.0)
> ==30295== by 0x8048DD1: getip (database.c:22)
> ==30295== by 0x80492DD: sockit (listener.c:50)
> ==30295== by 0x4378D4B: start_thread (pthread_create.c:308)
> ==30295== by 0x447BD3D: clone (clone.S:130)
> ==30295==
> ==30295== LEAK SUMMARY:
> ==30295== definitely lost: 128 bytes in 1 blocks
> ==30295== indirectly lost: 0 bytes in 0 blocks
> ==30295== possibly lost: 0 bytes in 0 blocks
> ==30295== still reachable: 73,744 bytes in 20 blocks
> ==30295== suppressed: 0 bytes in 0 blocks
> ==30295== Reachable blocks (those to which a pointer was found) are not shown.
> ==30295== To see them, rerun with: --leak-check=full --show-reachable=yes
関数が実行されるたびにリークが増加するため、エラーになります
私は何を間違っていますか?