因此,我不断free(): invalid next size(fast)遇到此错误:运行代码时。如果我在函数末尾删除了free,我知道我正在泄漏内存,但是我不明白为什么会收到此错误。
我认为这与我错误地分配内存有关,但是我似乎找不到解决方法,这是我的代码:
bool parse(const char* line) //NOT WORKING JUST QUITE
{
char* copy = malloc(sizeof(line)); //allocate space for a copy of the line parameter
strcpy(copy, line); //copy the line parameter
char* method = strtok(copy, " "); //pointer to the method
char* reqLine = strtok(NULL, " "); //pointer to the requestline
char* version = strtok(NULL, "\r\n"); //pointer to the HTTP-Version
if (strcmp(method,"GET") != 0) //if the method is not GET
{
printf("%s\n", method);
printf("ERROR 405\n");
return …Run Code Online (Sandbox Code Playgroud)