mtrace : Free was never allocated
Hi guys
mtrace log says :
Code:
- 0x0052cfc0 Free 21794 was never alloc'd /home/mtrace/oscam-garbage.c:100
- 0x2aa02220 Free 21919 was never alloc'd /home/mtrace/oscam-garbage.c:106
here is the releated source code :
Code:
void garbage_collector() {
time_t now;
int8_t i;
struct cs_garbage *garbage, *next, *prev;
while (garbage_collector_active) {
for(i = 0; i < HASH_BUCKETS; ++i){
cs_lock(&garbage_lock[i]);
now = time(NULL);
prev = NULL;
garbage = garbage_first[i];
while (garbage) {
next = garbage->next;
if (now > garbage->time+5) { //5 seconds!
if(garbage->data)
//This is oscam-garbage.c : Line 100 , mentioned in mtrace log
free(garbage->data);
if (prev)
prev->next = next;
else
garbage_first[i] = next;
//This is Oscam-garbage.c : line 106
if (garbage)
free(garbage);
}
else
prev = garbage;
garbage = next;
}
cs_unlock(&garbage_lock[i]);
}
cs_sleepms(1000);
}
pthread_exit(NULL);
}
I did several attempt ( to prevent that error log in mtrace , the error was gone , but seems after that , performance has been reduced (seems after my change more memory leaks happened , actually in while loop , before line 100 , i added line for malloc the garbage , but i know this is not the correct solution , That's why i ask)
would appreciate if some expert guide me , what is the best solution to fix this bug.(would be thankful , if u would write the code u are meaning , my reading (understanding) with the source code is sheer better than mu English technical concepts reading. :wink: )
p.s: here is entire oscam-garbage.c source code
Best Regards