You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by cm...@collab.net on 2003/01/24 15:08:16 UTC
Re: svn commit: rev 4559 - trunk/subversion/libsvn_subr
philip@tigris.org writes:
Author: philip
Date: 2003-01-24 06:40:32 -0600 (Fri, 24 Jan 2003)
New Revision: 4559
Modified:
trunk/subversion/libsvn_subr/path.c
Log:
Fix another memory problem tracked down with valgrind.
* subversion/libsvn_subr/path.c (svn_path_uri_encode): Allocate space for
sprintf null.
I was wondering the other day if we shouldn't just do a single
svn_stringbuf_ensure here. Either always do one at the beginning:
svn_stringbuf_ensure(retstr, strlen (path) * 3) + 1);
(This is worst case -- each char is replaced by three (%XX), and
then room for the NULL at the end)
Or, do it the first time we find a char that needs replacing (someone
check my math):
svn_stringbuf_ensure(retstr, copied + strlen (path + copied) * 3) + 1);
Anyway, just an idea.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: svn commit: rev 4559 - trunk/subversion/libsvn_subr
Posted by cm...@collab.net.
Greg Stein gstein@lyra.org writes:
On Fri, Jan 24, 2003 at 09:08:16AM -0600, cmpilato@collab.net wrote:
...
I was wondering the other day if we shouldn't just do a single
svn_stringbuf_ensure here. Either always do one at the beginning:
svn_stringbuf_ensure(retstr, strlen (path) * 3) + 1);
(This is worst case -- each char is replaced by three (%XX), and
then room for the NULL at the end)
Or, do it the first time we find a char that needs replacing (someone
check my math):
svn_stringbuf_ensure(retstr, copied + strlen (path + copied) * 3) + 1);
Anyway, just an idea.
In apr_xml_quote_string, I coded a two-pass algorithm. One pass to count
the special chars, do the alloc, then a second pass to make the changes. The
neat part is that if no changes are necessary, it just returns the input
string without an alloc/copy.
We could do the same pretty easily. The test for URI-safeness is easy
and fast, and this beats XML-encoding by just a hair on the size test
because it's a flat 1-char-to-3-chars expansion for each unsafe byte.
Wanna code it up?
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: svn commit: rev 4559 - trunk/subversion/libsvn_subr
Posted by Greg Stein gs...@lyra.org.
On Fri, Jan 24, 2003 at 09:08:16AM -0600, cmpilato@collab.net wrote:
...
I was wondering the other day if we shouldn't just do a single
svn_stringbuf_ensure here. Either always do one at the beginning:
svn_stringbuf_ensure(retstr, strlen (path) * 3) + 1);
(This is worst case -- each char is replaced by three (%XX), and
then room for the NULL at the end)
Or, do it the first time we find a char that needs replacing (someone
check my math):
svn_stringbuf_ensure(retstr, copied + strlen (path + copied) * 3) + 1);
Anyway, just an idea.
In apr_xml_quote_string, I coded a two-pass algorithm. One pass to count
the special chars, do the alloc, then a second pass to make the changes. The
neat part is that if no changes are necessary, it just returns the input
string without an alloc/copy.
Cheers,
-g
--
Greg Stein, http://www.lyra.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org