cn-uofbasel / ccn-lite

CCN-lite, a lightweight implementation of the CCNx protocol and its variations
ISC License
74 stars 63 forks source link

ccnl_core_addToCleanup in ccnl_buf.h #302

Closed mfrey closed 5 years ago

mfrey commented 5 years ago

I'm in the midst of refactoring the content store and its interface. I've stumbled upon ccnl_buf.h and was wondering about the ccnl_core_addToCleanup function. What's the purpose of this function? There are also small bits of it in ccnl-relay.h (a member called *bufCleanUpList) and also a global variable in the ccnl_buf.c. The feature however seems not to be used

$ git grep ccnl_core_addToCleanup
ccn-lite-simu.c:void ccnl_core_addToCleanup(struct ccnl_buf_s *buf);
ccnl-core/include/ccnl-buf.h:ccnl_core_addToCleanup(struct ccnl_buf_s *buf);
ccnl-core/src/ccnl-buf.c:ccnl_core_addToCleanup(struct ccnl_buf_s *buf)
ccnl-core/src/ccnl-prefix.c:        //ccnl_core_addToCleanup(b);
ccnl-core/src/ccnl-prefix.c:        //ccnl_core_addToCleanup(b);
ccnl-utils/include/ccnl-common.h:#define ccnl_core_addToCleanup(b)       do{}while(0)
ccnl-utils/src/ccnl-common.c:#define ccnl_core_addToCleanup(b)       do{}while(0)

Maybe I'm missing the point, but it seems to be that the functionality is broken. Is it safe to remove or is there a feature we should implement (and how)?

mfrey commented 5 years ago

I would also argue that the following code in ccnl_core_cleanup in ccnl_buf.c is never executed since bufCleanUpList is never initialized (ccnl_core_addToCleanup is never called).

 92     while (bufCleanUpList) {
 93         struct ccnl_buf_s *tmp = bufCleanUpList->next;
 94         ccnl_free(bufCleanUpList);
 95         bufCleanUpList = tmp;
 96     }
blacksheeep commented 5 years ago

this function was a garbage collecter. i think it was only used in NFN