On 11/18/2014 1:56 PM, "Ola Fosheim Grøstad" <ola.fosheim.grostad+dl...@gmail.com>" wrote:
Filenames are easy, just allocate a large fixed size buffer, then fill in.
open(). reuse buffer.

    char s[] = "filename.ext";
    foo(s[0..8]);

But hey, it's simpler, faster, less code, less bug prone, easier to understand and uses less memory to:

1. strlen
2. allocate
3. memcpy
4. append a 0
   foo
5. free

instead, right?

I know you said "just allocate a large fixed size buffer", but I hope you realize that such practice is the root cause of most buffer overflow bugs, because the "640K is enough for anyone" just never works.

And your "just use a struct" argument also promptly falls apart with:

    foo("string")

Now, I know that you'll never concede destruction, after all, this is the internet, but give it up :-)

Reply via email to