You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2012/08/03 23:47:32 UTC
svn commit: r1369221 - /subversion/trunk/subversion/libsvn_subr/debug.c
Author: julianfoad
Date: Fri Aug 3 21:47:31 2012
New Revision: 1369221
URL: http://svn.apache.org/viewvc?rev=1369221&view=rev
Log:
Adjust SVN_DBG to print into a stack buffer instad of an APR pool, to avoid
concerns about the size of the pool growing indefinitely. A follow-up to
r1369183.
Suggested by: gstein
* subversion/libsvn_subr/debug.c
(debug_pool): Remove.
(svn_dbg__preamble): Remove the creation of the pool.
(debug_vprintf): Use stack buffers.
Modified:
subversion/trunk/subversion/libsvn_subr/debug.c
Modified: subversion/trunk/subversion/libsvn_subr/debug.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/debug.c?rev=1369221&r1=1369220&r2=1369221&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/debug.c (original)
+++ subversion/trunk/subversion/libsvn_subr/debug.c Fri Aug 3 21:47:31 2012
@@ -25,6 +25,7 @@
be used in release code. One of the reasons to avoid this code in release
builds is that this code is not thread-safe. */
#include <stdarg.h>
+#include <assert.h>
#include <apr_pools.h>
#include <apr_strings.h>
@@ -37,7 +38,6 @@
#define DBG_FLAG "DBG: "
/* This will be tweaked by the preamble code. */
-static apr_pool_t *debug_pool = NULL;
static const char *debug_file = NULL;
static long debug_line = 0;
static FILE * volatile debug_output = NULL;
@@ -53,9 +53,6 @@ quiet_mode(void)
void
svn_dbg__preamble(const char *file, long line, FILE *output)
{
- if (! debug_pool)
- apr_pool_create(&debug_pool, NULL);
-
debug_output = output;
if (output != NULL && !quiet_mode())
@@ -80,15 +77,18 @@ static void
debug_vprintf(const char *fmt, va_list ap)
{
FILE *output = debug_output;
- const char *prefix;
- char *s;
+ char prefix[80], buffer[1000];
+ char *s = buffer;
+ int n;
if (output == NULL || quiet_mode())
return;
- prefix = apr_psprintf(debug_pool, DBG_FLAG "%s:%4ld: ",
- debug_file, debug_line);
- s = apr_pvsprintf(debug_pool, fmt, ap);
+ n = apr_snprintf(prefix, sizeof(prefix), DBG_FLAG "%s:%4ld: ",
+ debug_file, debug_line);
+ assert(n < sizeof(prefix) - 1);
+ n = apr_vsnprintf(buffer, sizeof(buffer), fmt, ap);
+ assert(n < sizeof(buffer) - 1);
do
{
char *newline = strchr(s, '\n');