[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r999507 - in /subversion/trunk/subversion: svnrdump/dump_editor.c tests/cmdline/svnrdump_tests.py

From: Ramkumar Ramachandra <artagnon_at_gmail.com>
Date: Thu, 23 Sep 2010 09:15:15 +0530

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
Received on 2010-09-23 05:47:30 CEST

This is an archived mail posted to the Subversion Dev mailing list.