Dear all, this is Daniel Juyung Seo. I propose EFL_SAFE_FREE macro for efl. It looks like:
# define EFL_SAFE_FREE(_h, _fn) do { if (_h) { _fn((void*)_h); _h = NULL; } } while (0) As I have been using ELM_SAFE_FREE for months, I found out that this macro is quite useful in terms of code readability, reducing human mistakes, and using much smaller number of lines with the same functionality. Enlightenment has # define E_FREE_FUNC(_h, _fn) do { if (_h) { _fn((void*)_h); _h = NULL; } } while (0) Elementary has #define ELM_SAFE_FREE(_h, _fn) do { if (_h) { _fn((void*)_h); _h = NULL; } } while (0) So why not efl? By using EFL_SAFE_FREE, this (Old) code will reborn as a (New) code. 5 lines down to 1 line. (Old) if (svr->until_deletion) { ecore_timer_del(svr->until_deletion); svr->until_deletion = NULL; } (New) EFL_SAFE_FREE(svr->until_deletion, ecore_timer_del); This can be used for any function that gets one parameter for its deletion, removal, free, and etc. ecore_timer_del, evas_object_del, free, eina_stringshare_del, ecore_animator_del, eina_hash_free, ecore_thread_cancel, ecore_job_del, ecore_event_handler_del, ecore_idle_enterer_del, ecore_idler_del, ecore_poller_del, eina_inlist_sorted_state_free, and etc. Of course this macro is not a silver bullet and should not be overused. So use it only when you have to. There was a discussion about ELM_SAFE_FREE macro this May with regarding to its usage and its name. Please refer the following link. http://sourceforge.net/mailarchive/message.php?msg_id=30901033 I also talked this with Carsten Raster Haitzler and Cedric Da B0rker Bail and got no objection. If noone objects to this idea. I will apply this to efl soon. Thanks. Best Regards, Daniel Juyung Seo. ------------------------------------------------------------------------------ Sponsored by Intel(R) XDK Develop, test and display web and hybrid apps with a single code base. Download it for free now! http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel