Ok. 그래서이 함수는 init()입니다.매우 이상한 malloc 오류
void init()
{
fstream file;
int index = 0;
char temp_list[60000][15];
listlen = 0;
current_index = 0;
file.open("en_US.dic");
while(!file.eof())
{
file >> temp_list[index];
index++;
}
listlen = index;
file.close();
file.open("en_US.dic");
word_list = new char*[listlen];
int count = 0;
for(int i = 0; i < listlen; i++)
{
word_list[i] = new char[21];
file >> word_list[i];
}
file.close();
}
이 코드는 오류없이 올바르게 컴파일되고 실행됩니다. 내가 선
word_list[i] = new char[21]
나는 다음과 같은 오류가
word_list[i] = new char[x] //x < 21
로를 변경할 때 그러나 :
dict: malloc.c:3074: sYSMALLOc: Assertion `(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)' failed.
나는 프로그래밍 (< 2 년) 다소 새로운 해요, 그리고 나는 이런 것을 본적이 없다. 누구든지 아이디어가 있습니까? 미리 감사드립니다!
어디에도 x가 표시되지 않습니까? x는 무엇으로 설정되어 있습니까? – Pace
플랫폼이란 무엇입니까? 컴파일러? –
제쳐두고, 파일의 끝 부분에 대한 점검이 잘못되었습니다. http://stackoverflow.com/questions/21647/ –