Here's my piece of code(the purpose is to read line and make a structure out of it):
typedef struct{
size_t length;
char *letters;
}line;
static line ReadLine(){
char *buffor = NULL;
size_t length = 0;
int nRead = 0;
nRead = getline(&buffor, &length, stdin);
return nRead == -1 ? (line) {.length = 0, .letters = NULL} : (line) {.length = nRead, .letters = buffor};
}
Later on in my main function I free the buffor that was allocated by getline function:
void ReadFile(){
line l = ReadLine();
printLine(l);
free(l.letters);
}
And yet i get that there is some memory(using valgrind): Leak_StillReachable by malloc in which the function getline is.