In many cases, obj is already checked and it does more things like:

if (obj)
  {
     evas_object_del(obj);
     obj = NULL;
     do_something_else();
  }

As Rafael mentioned we don't need to check the same thing twice.
That is why I want to distinguish FREE and FREE_IF.

Thanks.

Daniel Juyung Seo (SeoZ)



On Tue, May 28, 2013 at 11:02 PM, ChunEon Park <her...@naver.com> wrote:

>  I think,
>
> ELM_SAFE_FREE(obj, evas_object_del)
> if (obj)
>   {
>      evas_object_del(obj);
>      obj = NULL;
>   }
>
> is enough
>
> does it need both FREE and FREE_IF?
>
>
> ------------------------------------
> -Regards, Hermet-
>
> -----Original Message-----
> From: "Daniel Juyung Seo"<seojuyu...@gmail.com>
> To: "Enlightenment developer list"<
> enlightenment-devel@lists.sourceforge.net>;
> Cc:
> Sent: 2013-05-28 (화) 22:47:29
> Subject: Re: [E-devel] [EGIT] [core/elementary] master 01/01: elm: more
> ELM_FREE_FUNC cleanups.
>
> Cool I like the word "SAFE". But I still prefer "FREE".
> So I suggest
>
> 1. ELM_SAFE_FREE(obj, evas_object_del)
> evas_object_del(obj);
> obj = NULL;
>
> 2. ELM_SAFE_FREE_IF(obj, evas_object_del)
> if (obj)
>   {
>      evas_object_del(obj);
>      obj = NULL;
>   }
>
> 3. no macro
> evas_object_del(obj);
>
> Thanks a lot.
>
> Daniel Juyung Seo (SeoZ)
>
>
>
> On Tue, May 28, 2013 at 10:05 PM, ChunEon Park <hermet>@naver.com> wrote:
>
> > We can use the macro what it really helpful but not everywhere.
> >
> > if it needs to be null set, then
> > ELM_SAFE_DEL(ecore_animator_del, animator);
> > ELM_SAFE_DEL(evas_object_del, obj);
> > ...
> >
> > otherwise, below looks enough.
> >
> > ecore_animator_del(animator);
> > evas_object_del(obj);
> >
> >
> >
> > ------------------------------------
> > -Regards, Hermet-
> >
> > -----Original Message-----
> > From: "Daniel Juyung Seo"<seojuyung2>@gmail.com>
> > To: "Enlightenment developer list"<
> > enlightenment-devel@lists.sourceforge.net>;
> > Cc:
> > Sent: 2013-05-28 (화) 14:06:19
> > Subject: Re: [E-devel] [EGIT] [core/elementary] master 01/01: elm: more
> > ELM_FREE_FUNC cleanups.
> >
> > On Tue, May 28, 2013 at 2:58 AM, Rafael Antognolli <antognolli>@
> gmail.com
> > >wrote:
> >
> > > On Thu, May 23, 2013 at 12:58 PM, Daniel Juyung Seo - Enlightenment
> > > Git <no-reply>@enlightenment.org> wrote:
> > > > seoz pushed a commit to branch master.
> > > >
> > > > commit 2b25732ad24a68a309f60d702087bab673e3576c
> > > > Author: Daniel Juyung Seo <seojuyung>@gmail.com>
> > > > Date:   Fri May 24 00:58:38 2013 +0900
> > > >
> > > >     elm: more ELM_FREE_FUNC cleanups.
> > > > ---
> > > >  src/lib/elm_box.c                    12 +--
> > > >  src/lib/elm_cnp.c                     7 +-
> > > >  src/lib/elm_flip.c                    6 +-
> > > >  src/lib/elm_gengrid.c                 5 +-
> > > >  src/lib/elm_genlist.c                29 ++------
> > > >  src/lib/elm_interface_scrollable.c  146
> > > ++++++++++---------------------------
> > > >  src/lib/elm_transit.c                 6 +-
> > > >  src/lib/elm_web.c                    15 +---
> > > >  src/lib/elu_ews_wm.c                 30 ++------
> > > >  9 files changed, 63 insertions(+), 193 deletions(-)
> > >
> > >
> > > > --- a/src/lib/elm_gengrid.c
> > > > +++ b/src/lib/elm_gengrid.c
> > > > @@ -1240,9 +1240,8 @@ _item_place(Elm_Gen_Item *it,
> > > >                 }
> > > >               else if (item->item_reorder_move_animator)
> > > >                 {
> > > > -                  ecore_animator_del
> > > > -                    (item->item_reorder_move_animator);
> > > > -                  item->item_reorder_move_animator = NULL;
> > > > +                  ELM_FREE_FUNC(item->item_reorder_move_animator,
> > > > +                                ecore_animator_del);
> > > >                    item->moving = EINA_FALSE;
> > > >                 }
> > > >            }
> > > > diff --git a/src/lib/elm_genlist.c b/src/lib/elm_genlist.c
> > > > index 8b7e4e9..420347c 100644
> > > > --- a/src/lib/elm_genlist.c
> > > > +++ b/src/lib/elm_genlist.c
> > > > @@ -3066,8 +3066,7 @@ _item_del(Elm_Gen_Item *it)
> > > >          if (sd->tree_effect_animator)
> > > >            {
> > > >               _item_tree_effect_finish(sd);
> > > > -             ecore_animator_del(sd->tree_effect_animator);
> > > > -             sd->tree_effect_animator = NULL;
> > > > +             ELM_FREE_FUNC(sd->tree_effect_animator,
> > > ecore_animator_del);
> > > >            }
> > > >          sd->expanded_item = NULL;
> > > >          sd->move_effect_mode = ELM_GENLIST_TREE_EFFECT_NONE;
> > >
> > > Here you changed the code to:
> > >
> > > if (sd->tree_effect_animator)
> > >   {
> > >       _item_tree_effect_finish(sd);
> > >       if (sd->tree_effect_animator)
> > >         {
> > >            ecore_animator_del(sd->tree_effect_animator);
> > >            sd->tree_effect_animator = NULL;
> > >         }
> > >   }
> > >
> > > I didn't check all of these changes, but I fear that a lot of
> > > redundancy like this is being added all over the code.
> > >
> > >
> > Yes you are right and as discussed in another mail thread I was aware of
> > that before I committed this.
> > But I found out there are so many human mistakes in elementary, so I
> wanted
> > to force to use the macro.
> > Of course, it's not that optimized anyway, so I am on my way to clean
> this
> > up.
> > Maybe I should modify macros.
> >
> > 1. ELM_IF_FREE_FUNC
> > if -> del -> set to null
> >
> > 2. ELM_FREE_FUNC
> > del -> set to null
> >
> > But having multiple macros for similar tasks is also confusing.
> > So I welcome any kind of opinion.
> > Anyhow, thanks for your reply and consideration.
> >
> > Please consider this as an effort to reduce many bugs in elementary.
> > Thanks.
> >
> > Daniel Juyung Seo (SeoZ)
> >
> >
> >
> > > --
> > > Rafael Antognolli
> > >
> > >
> > >
> >
> ------------------------------------------------------------------------------
> > > Try New Relic Now & We'll Send You this Cool Shirt
> > > New Relic is the only SaaS-based application performance monitoring
> > service
> > > that delivers powerful full stack analytics. Optimize and monitor your
> > > browser, app, & servers with just a few lines of code. Try New Relic
> > > and get this awesome Nerd Life shirt!
> > http://p.sf.net/sfu/newrelic_d2d_may
> > > _______________________________________________
> > > enlightenment-devel mailing list
> > > enlightenment-devel@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
> > >
> >
> >
> ------------------------------------------------------------------------------
> > Try New Relic Now & We'll Send You this Cool Shirt
> > New Relic is the only SaaS-based application performance monitoring
> service
> > that delivers powerful full stack analytics. Optimize and monitor your
> > browser, app, & servers with just a few lines of code. Try New Relic
> > and get this awesome Nerd Life shirt!
> http://p.sf.net/sfu/newrelic_d2d_may
> > _______________________________________________
> > enlightenment-devel mailing list
> > enlightenment-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
> >
> >
> >
> ------------------------------------------------------------------------------
> > Try New Relic Now & We'll Send You this Cool Shirt
> > New Relic is the only SaaS-based application performance monitoring
> service
> > that delivers powerful full stack analytics. Optimize and monitor your
> > browser, app, & servers with just a few lines of code. Try New Relic
> > and get this awesome Nerd Life shirt!
> http://p.sf.net/sfu/newrelic_d2d_may
> > _______________________________________________
> > enlightenment-devel mailing list
> > enlightenment-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
> >
>
> ------------------------------------------------------------------------------
> Try New Relic Now & We'll Send You this Cool Shirt
> New Relic is the only SaaS-based application performance monitoring service
> that delivers powerful full stack analytics. Optimize and monitor your
> browser, app, & servers with just a few lines of code. Try New Relic
> and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
> _______________________________________________
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>
> ------------------------------------------------------------------------------
> Try New Relic Now & We'll Send You this Cool Shirt
> New Relic is the only SaaS-based application performance monitoring service
> that delivers powerful full stack analytics. Optimize and monitor your
> browser, app, & servers with just a few lines of code. Try New Relic
> and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
> _______________________________________________
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to