- 论坛徽章:
- 0
|
有了新错误
GDB提示:
CombineWRDList CombineWRDList CombineWRDList
00000000000000000000
-1-1-1-1-1-1-1-1-
Program received signal SIGSEGV, Segmentation fault.
0x4207c1ac in memcpy () from /lib/tls/libc.so.6
(gdb) bt
#0 0x4207c1ac in memcpy () from /lib/tls/libc.so.6
#1 0x08049501 in CombineWRDList (p1=0x4, p2=0xbffff304) at event_list.c:375
#2 0x0804b75a in main (argc=4, argv=0xbffff304) at main.c:826
#3 0x42015574 in __libc_start_main () from /lib/tls/libc.so.6
(gdb)
我的函数:
void CombineWRDList(WREVENT_DNODE *p1, EVENT_DNODE *p2)
{
long count;
int len;
struct in_addr *ptr;
count = p1->event.count;
len = (p1->aipinf.size + p2->aipinf.size);
p1->event = p2->event;
p1->event.count = p1->event.count + count;
printf("CombineWRDList CombineWRDList CombineWRDList\n");
printf("00000000000000000000\n");
if(p1->aipinf.front != NULL)
{
ptr = (struct in_addr *)realloc(p1->aipinf.front, sizeof(struct in_addr)*len);
printf("-1-1-1-1-1-1-1-1-\n");
memcpy(ptr+(p1->aipinf.size), p2->aipinf.front, sizeof(struct in_addr)*(p2->aipinf.size)); //我把ptr的偏移位置改了,没有乘sizeof(struct in_addr)
printf("11111111111111\n");
p1->aipinf.front = ptr;
printf("22222222\n");
p1->aipinf.size = len;
if(p2->aipinf.front != NULL)
{
free(p2->aipinf.front);
p2->aipinf.front = NULL;
printf("33333333333\n");
}
}
else
{
p1->aipinf.front = p2->aipinf.front;
p2->aipinf.front = NULL;
printf("44444444444444\n");
p1->aipinf.size = len;
}
p2->aipinf.size = 0;
printf("5555555555555555555\n");
}
现在GDB提示出错在memcpy,大家看看什么原因. |
|