[physfs] Replace malloc/strcpy by strdup

Christoph Nelles evilazrael at evilazrael.de
Wed Sep 29 13:29:40 EDT 2010

Am 29.09.2010 18:07, schrieb Tim Cas:
> >Perhaps, it might be an idea to get rid of dynamically allocated
> >path strings, and use arrays instead ? This might vastly improve
> >performance at cost of memory, I suspect.
> You mean using "char foo[5]" as opposed to "char* foo = malloc(5)"? I'm
not sure what you mean because dynamically allocated path strings are
pretty much arrays (all strings are).
> If you do mean using foo[5], then there's no change, only that it
allocates things on the stack, which is much more limited and can have
horrible consequences if an overflow happens. Furthermore, the size is
fixed, meaning that you can't, in this extreme case, use the path
"hello" because it uses 6 characters ("hello" + \0 termination).

yeah, but's it allocated on the stack which normally much faster than a
call to malloc/free.

Christoph Nelles

E-Mail    : evilazrael at evilazrael.de
Jabber    : eazrael at evilazrael.net      ICQ       : 78819723

PGP-Key   : ID 0x424FB55B on subkeys.pgp.net
            or http://evilazrael.net/pgp.txt

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://icculus.org/pipermail/physfs/attachments/20100929/4dbcef5b/attachment.htm>

More information about the physfs mailing list