小编Sil*_*Rab的帖子

Free():无效的下一个尺寸(快速)错误

因此,我不断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)

c string malloc free pointers

4
推荐指数
1
解决办法
1986
查看次数

标签 统计

c ×1

free ×1

malloc ×1

pointers ×1

string ×1