www.a00.de > tcpgroup > 1995 > msg00092
 

TCP-group 1995


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

Re: NOTICE-WARNING- TIME BOMB!!



> From: Phil Karn <karn@qualcomm.com>
> One of the items on my list of things-to-do for my next release of NOS
> (yes! I really do plan such a thing!) is a set of macro wrappers for
> all functions that free pointer args.
>
> For example, I'll create the following macro:
>
> #define	FREE_P(x)	{free_p(x); x = NULL;}
>
> and then replace all calls to the function free_p() with calls to the
> macro FREE_P().
>
Phil, it would be better to change free_p to match free_q, and use a
pointer, as in free_p( struct mbuf **bpp ).

Then, put the *bpp = NULL; in the free routine.  Saves code space and
execution time, and makes the calling parameters more consistent with
other mbuf routines.

This ensures that you find all the free_p, from the compiler errors.
Most of them won't change anything, since the pointers are often tossed
immediately afterwards, so the macro form would only add excess code.

The real answer is to change a lot of *bp to **bpp, which would allow
the freeing of the buffers at lower levels to be reflected in callers.

For example, when enqueuing, the bp should be NULL afterward, so that it
can't be accidentally used again later.  All the _send routines would
need this, too.  It's a lot of hand work, but very useful.

Actually, I also renamed some of the free_p to free_packet, and free_q
for free_queue, after some embarassing typos.  So, today, I just changed
all the _p to _packet, and _q to _queue.  Found several more mistyped
(len_p instead of len_q in locsock.c).

Bill.Simpson@um.cc.umich.edu





Document URL : http://www.a00.de/tcpgroup/1995/msg00092.php
Ralf D. Kloth, Ludwigsburg, DE (QRQ.software). < hostmaster at a00.de > [don't send spam]
Created 2005-01-02. Last modified 2005-01-02. Your visit 2024-04-19 21:23.49. Page created in 0.0219 sec.
 
[Go to the top of this page]   [... to the index page]