我在多次连接数据库的时候无法连接,具体在mysql_init()的时候,使用GDB调试信息:Program received signal SIGSEGV, Segmentation fault.
malloc_consolidate (av=0x5c03a0) at malloc.c:5167
5167     if (!nextinuse) {
(gdb) bt
#0  malloc_consolidate (av=0x5c03a0) at malloc.c:5167
#1  0x004a881d in _int_malloc (av=0x5c03a0, bytes=964) at malloc.c:4373
#2  0x004ab070 in __libc_malloc (bytes=964) at malloc.c:3660
#3  0x00c23a20 in my_malloc (size=964, my_flags=48) at my_malloc.c:37
#4  0x00c4cebc in mysql_init (mysql=0x0) at client.c:1541
#5  0x0804a6d3 in mysql_connection () at src/mydb.c:12
#6  0x0804aa43 in insertRequest (taskid=90, type=1, 
    content=0x804c871 "http://www.baidu.com/", status=-1, 
    commitTime=1334033629, md5=0x814c2d8 "f03f5717616221de41881be555473a02")
    at src/mydb.c:147
#7  0x0804b6aa in newRequest (taskid=90, url=0x804c871 "http://www.baidu.com/")
    at src/request.c:35
#8  0x0804bdf8 in newTask (userid=12, url=0x804c871 "http://www.baidu.com/")
    at src/task.c:24
#9  0x0804c07a in addTask (userid=12, url=0x804c871 "http://www.baidu.com/")
    at src/user.c:71
#10 0x08049161 in user_thread (arg=0x0) at src/main.c:74
#11 0x0804987c in main (argc=1, argv=0xbffff074) at src/main.c:390
具体代码中是在关系实现为:
int C()
{
    //连接数据库,插入
    return id;
}
int B()
{
    //连接数据库,插入
    C();
    return id;
}
int A()
{
     //连接数据库,插入
     B();
    return id;
}
int main()
{
    A();
}在主函数中调用A,A中调用B,B中调用C,分别向数据库中插入数据。
但是在调用C函数中使用mysql_init()就会出错,错误信息如上面gdb给出的,如果将C函数删除,则在B函数中mysql_init()也会出一样的错.希望大家帮帮忙,搞了好长时间,头都大了