On Wed, 05 Jan 2011 08:51:01 +0100 Sebastian Dransfeld <s...@tango.flipp.net> said:
> On 01/04/2011 11:03 PM, Gustavo Sverzut Barbieri wrote: > > On Tue, Jan 4, 2011 at 7:53 PM, Vincent Torri<vto...@univ-evry.fr> wrote: > >> On Tue, 4 Jan 2011, Mike Blumenkrantz wrote: > >> > >>> In my efm hacking, I've found a number of snippets like this: > >>> > >>> size = strlen(v->udi) + 1; > >>> buf = alloca(size); > >>> strcpy(buf, v->udi); > >>> ecore_ipc_server_send(_e_fm_ipc_server, > >>> 6 /*E_IPC_DOMAIN_FM*/, > >>> E_FM_OP_EJECT_DONE, > >>> 0, 0, 0, buf, size); > >>> > >>> Is there a reason why we can't just use strdupa? It should be about as > >>> portable as alloca... > >> > >> strdupa is not portable at all. It is part of the glibc (it's a GNU > >> stuff). > > > > given that the above code does exactly what strdupa() would do, why > > not use it and save lines, defining a strdupa() macro where not > > available? > > > > something like this should do: > > > > #define stdupa(str) strcpy(alloca(strlen(str) + 1), str) > > > > > > But it's better to use memcpy since we know the string length. not like it will really matter unless we get a huge amount of such copying going on... :) just remember to memcpy len + 1 :) -- ------------- Codito, ergo sum - "I code, therefore I am" -------------- The Rasterman (Carsten Haitzler) ras...@rasterman.com ------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel