Coding a getline() implementation - Valgrind errors

前端 未结 2 1310
温柔的废话
温柔的废话 2020-12-22 08:24

I have to recode an implementation of the getline() function, but using the file descriptor of the file and not a FILE *. I am only allowed to use

2条回答
  •  情书的邮戳
    2020-12-22 08:48

    I am concerned about this line:

    remaining = remaining + i + 1;
    

    remaining is a pointer to the allocated buffer. On this line, you destroy it, which means that you cannot free() it anymore.

提交回复
热议问题