Hirohito Higashi wrote:

> > > > > Patch 8.0.1481
> > > > > Problem:    Clearing a pointer takes two lines.
> > > > > Solution:   Add vim_clear() to free and clear the pointer.
> > > > > Files:      src/misc2.c, src/proto/misc2.pro, src/edit.c
> > > > [...]
> > > > 
> > > > 
> > > > In todo.txt
> > > > > Use vim_clear() in more places, instead of vim_free() and assigning 
> > > > > NULL.
> > > > 
> > > > I am working on the above items now.
> > > > Wait about 6 hours.
> > > > 
> > > > Remarks:
> > > > It includes the following changes.
> > > > - Since cast is dangerous and troublesome, I changed vim_clear() from
> > > > function to macro.
> > > > 
> > > > #define VIM_CLEAR(p) \
> > > >     do { \
> > > >         vim_free(p); \
> > > >         p = NULL; \
> > > >     } while (0)
> > > 
> > > I want to avoid using a macro, because the argument may not be a simple
> > > pointer.
> > 
> > Hmm, at least my modified parts were all simple pointers.
> 
> I found not a simple pointer with vim_free() in Patch 8.0.1492.
> +                 vim_free(array[--size].pum_text);
> 
> Certainly, passing `array[--size].pum_text` to the VIM_CLEAR() macro
> will cause unintended behavior due to side effects of macros...

But the pointer isn't cleared, thus the marcro would not be used here.
It is logical, since storing the NULL requires the same pointer, thus
there can't be side effects.

-- 
    [clop clop]
ARTHUR:  Old woman!
DENNIS:  Man!
ARTHUR:  Man, sorry.  What knight lives in that castle over there?
DENNIS:  I'm thirty seven.
ARTHUR:  What?
DENNIS:  I'm thirty seven -- I'm not old!
                                  The Quest for the Holy Grail (Monty Python)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui