朋友你好我使用malloc的錯誤代碼是3096有一個問題:ç的malloc錯誤代碼:3096個
malloc.c:3096:SYSMALLOC:斷言`(old_top ==(((mbinptr) ((char *)&((av) - > bins [((1) - 1)* 2]))__builtin_offsetof(struct malloc_chunk,fd))))& & old_size == 0)|| ((unsigned long)(old_size)> =(unsigned long)((((_builtin_offsetof(struct malloc_chunk,fd_nextsize))+((2 *(sizeof(size_t)))-1)&〜((2 * (爲size_t))) - 1)))& &((old_top) - >大小爲0x1 &)& &((無符號長整數)OLD_END & pagemask)== 0)」失敗。 中止
代碼:
char *malloc_tab(char *str)
{
if ((str = malloc(1024)) == NULL)
return (NULL);
return (str);
}
int *malloc_tab_int(int *str)
{
int i;
i = 0;
if ((str = malloc(1024)) == NULL)
return (NULL);
while (i != 1024)
{
str[i] = 0;
i = i + 1;
}
return (str);
}
char **malloc_dim_tab(char **str)
{
int y;
y = 0;
if ((str = malloc(1024 * sizeof(*str))) == NULL)
return (NULL);
while (y < 200)
{
if ((str[y] = malloc(1024 * sizeof(**str))) == NULL)
return (NULL);
y = y + 1;
}
return (str);
}
任何幫助,請!
3096是不是錯誤代碼,它是失敗的斷言的源代碼行數當你看到foobar.c:1234的形式時,通常意味着foobar.c的1234行。 – Sneftel