On Wed, 17 Oct 2012 11:46:40 -0300 Leandro Pereira <lean...@profusion.mobi>
said:

> On 10/17/2012 11:27 AM, Carsten Haitzler (The Rasterman) wrote:
> > how could i do something convenient like
> >
> > obj =  eo_add(class, parent,
> >                GEOMETRY(10, 20, 50, 30),
> >                FILE_SET(file_find("image.jpg")),
> >                GROUP_SET(group_find("base")));
> >
> > the only way is to provide a buffer to snprintf into OR to return a
> > strduped or strinshare'd string... the problem is all our existing api
> > doesn't free this string afterwards.
> 
> Why not always stringshare these strings, regardless of them being 
> constant or heap-allocated, and provide something like:
> 
> void *
> idle_free(void *ptr)
> {
>     idler_add(free, ptr);
>     return ptr;
> }
> 
> So you can do:
> 
> char *
> file_find(const char *name)
> {
>     char *tmp = malloc(...);
>     ...
>     return idle_free(tmp);
> }
> 
> Since you're not going to run your main loop while constructing the 
> object (and thus calling the idler callback), and since eo_add() will 
> now manage all strings by using stringshare, this is safe, small, and 
> poses no additional overhead if you use static strings except for 
> stringshare, which is already pretty efficient. Of course, if your main 
> loop runs while you're running eo_add(), all hell breaks loose, but then 
> you deserve it anyway.

because this creates complexity and unexpected usage. now you HAVE to
stringshare every string passed into a function. tmpstr allows you to do what
you do now and what happens with every open() fopen(), unlink(),
evas_object_file_set() etc. etc. etc. function - you can pass in any string you
like and it works. in ADDITION if you pass in a tmpstr it is cleaned up for you
too.

-- 
------------- Codito, ergo sum - "I code, therefore I am" --------------
The Rasterman (Carsten Haitzler)    ras...@rasterman.com


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to