Hi, Daniel Shahaf writes: > abspath is a pointer, lives on the stack, and is passed by value (like > any old int) in function calls. What you allocate from the pool is the > value it points to --- i.e., the two bytes of "/". > > However, literal string constants are static strings --- they are loaded > into memory from the binary image (ever tried 'strings /usr/bin/svn'?) > and stay there until that is unloaded --- while pool-allocated strings > allocated on the heap, and stays there until the pool is cleared. > The other difference is that literal strings are not writable (they are > const char *) while pool-allocate strings are mutable (non-const char *). > > (waiting to hear from you that dropping the strdup() causes a segfault)
Hehe. See my other email- don't worry, I wasn't confused about static and dynamic allocation :p I just got muddled up in my whole "elegance" argument. > So, the only reasons you'd have to duplicate a static string is if the > static string lives in a library which you know you'll unload[1] or if > you need a non-const char * for some reason. In your case, 'abspath' is > a const char *, so neither of these cases applies. Right, it's been justified then- I was being silly. > Okay? Thanks for the explanation. Will drop during the cleanup. -- Ram