我不断收到此错误vidprocess: malloc.c:2451: 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.
我在这一步只释放一次内存:
DIR *dp;
struct dirent *ep;
dp = opendir (folder_input);
if (dp != NULL) {
while ( (ep = readdir (dp)) && MAXVIDS != 0 ) {
char *filename;
filename = malloc(sizeof(char) * strlen(ep->d_name));
strcpy(filename, ep->d_name);
int len = strlen(filename);
char *last_three = &filename[len-3];
char trailer_file_name[100];
int in_if = 0;
if (strcasecmp(last_three, "MOV") == 0) {
strcpy(trailer_file_name, ep->d_name);
MAXVIDS--;
in_if = 1;
}
else if (strcasecmp(last_three, "MP4") == 0) {
strcpy(trailer_file_name, ep->d_name);
MAXVIDS--;
in_if = 1;
}
free(filename);
这是我唯一使用的地方free()
。如果我不使用这部分,我不会收到上面的错误,所以我只是假设由于内存释放而出现错误,但我不明白为什么这是错误的?