Hello All,

I am facing assertion fail issue in pbuf_free API. The code where assert fails is mentioned below.

if ((p->flags & PBUF_FLAG_IS_CUSTOM) != 0)
      {
        struct pbuf_custom *pc = (struct pbuf_custom *)p;
        LWIP_ASSERT("pc->custom_free_function != NULL",
                    pc->custom_free_function != NULL);
        pc->custom_free_function(p);
      }

 

I have two queries :

1. Is it proper to typecast struct pbuf to struct pbuf_custom as in above code "struct pbuf_custom *pc = (struct pbuf_custom *)p;", as if the condition in if statement is true, then pbuf "p" should be a member of some struct of type pbuf_custom and hence typecasting like this is improper.

2. If the typecasting is proper:

Although its good to have assertion check, but may I know in which scenario this assertion can fail ? Because whenever the flag PBUF_FLAG_IS_CUSTOM is set only at one place i.e. in "pbuf_alloced_custom" API, and if that API returns properly, then custom_free_function member of strct pbuf_custom is always set to "ipfrag_free_pbuf_custom" and hence assertion fail should not happen.

Please help me out where I am going wrong in my understanding.

 

Thanks,

Arpit

 


_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to