p1 pointer is used in other functions without any change. and when it is not needed any more free_stuffs
function is called but when free_stuffs
is called, I get double free or corruption (out)
Aborted (core dumped)
char **someFunction(){
const char ** p1 = (char **)malloc(total * sizeof(char *));
for (int i = 0; i <= total; i++){
*(p1 + i) = (char *)malloc(len * sizeof(char) +1);
}
return p1;
}
void free_stuffs(char ** p1){
for (int i = 0; i <= total; i++){
free(p1[i]);
}
free(p1);
}