lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [patch #7088] Support for mem_realloc moving memory


From: Ken Smith
Subject: [lwip-devel] [patch #7088] Support for mem_realloc moving memory
Date: Thu, 18 Feb 2010 20:16:03 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.6) Gecko/20100107 Fedora/3.5.6-1.fc12 Firefox/3.5.6

Follow-up Comment #10, patch #7088 (project lwip):

I consider it a mistake to rely in realloc not moving memory since realloc
has been allowed to move the pointer since C89 and probably before.

If an allocation has multiple owners and one of them reallocs, that is
dangerous anyway because realloc has traditionally always implied a potential
free.

The only place I encountered this as I mentioned in my original problem
report is in the DNS module.  The lifetime of the allocation for struct pbuf*
p in dns_send is the duration of that function and no further.  There is one
owner.  When pbuf_realloc moves the allocation in my implementation, the
subsequent free was an error.  I have worked around this problem using the
patch I have submitted to your consideration.  If lwIP is implemented in such
a way that it cannot tolerate the possibility that realloc might move the
pointer, then so be it.  But I would hope that those places where that might
be a problem could be fixed.

Finally, please keep in mind that this patch only affects the behavior of RAM
pbufs.  Many of the instances where there might be multiple pointers to
allocations happen due to the linked lists of pool pbufs.  This patch will
never modify those pbuf's addresses.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?7088>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]