概述
运行我的尝试程序时,我一直收到错误 .
a.out:malloc.c:2372: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 *(sizeof( size_t))) - 1)))&&((old_top) - > size&0x1)&&((unsigned long)old_end&pagemask)== 0)'失败 .
我的代码是:
#include
#include
#include
typedef struct nodeData
{
char ch; /* This structure looks like a linked list */
struct nodeData *next;
}node;
typedef struct tries
{
node *start[26];
}tries;
tries *makeAllNull(tries *root)
{
int i=0;
for(i=0;i<=26;i++)
{
root->start[i] = NULL;
}
return root;
}
/* Insert the given string in to the tries */
tries *insert(tries *root,char *str,int len)
{
int i=0;
tries *temp;
temp = (tries *)malloc(sizeof(tries));
while(i
{
int k = str[i] - 'a';
temp->start[k] = (node *)malloc(sizeof(struct nodeData));
temp->start[k]->ch = str[i];
temp->start[k]->next = NULL;
if(temp->start[k] == NULL)
{
root->start[k] = temp->start[k];
}
else{
root->start[k]->next = temp->start[k];
}
i++;
}
return root;
}
int main()
{
int i=0;
tries *root;
root = (tries *)malloc(sizeof(node *));
makeAllNull(root);
char str[30];
while(i<5)
{
scanf("%s",str);
root = insert(root,str,strlen(str));
}
return 0;
}
最后
以上就是和谐小蘑菇为你收集整理的java malloc,尝试:为什么malloc错误来了的全部内容,希望文章能够帮你解决java malloc,尝试:为什么malloc错误来了所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复