您好朋友我在使用 malloc 时遇到问题,错误代码是 3096:
malloc.c:3096: sSYSMALLOc: 断言`(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 * (sizeof (size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)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);
}
任何帮助请!