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. Cheers, Leandro ------------------------------------------------------------------------------ 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