[physfs] Replace malloc/strcpy by strdup
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" 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, 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.
E-Mail : evilazrael at evilazrael.de
Jabber : eazrael at evilazrael.net ICQ : 78819723
PGP-Key : ID 0x424FB55B on subkeys.pgp.net
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the physfs