subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1674487 - /subversion/trunk/subversion/svn/conflict-callbacks.c
Date Sat, 18 Apr 2015 12:14:34 GMT
Author: brane
Date: Sat Apr 18 12:14:34 2015
New Revision: 1674487

URL: http://svn.apache.org/r1674487
Log:
Follow up to r1667699 and r1667700: Revert to using a stack-based array
instead of a heap-allocated array, but do make sure that the calculated
array size is both sufficiently large and a compile-time constant.

* subversion/svn/conflict-callbacks.c
  (MAX_ARRAY_LEN): New macro; expands to a compile-time constant
   whose value is the larger of two array sizes.
  (handle_text_conflict): Allocate the 'options' array on the stack.

Modified:
    subversion/trunk/subversion/svn/conflict-callbacks.c

Modified: subversion/trunk/subversion/svn/conflict-callbacks.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/conflict-callbacks.c?rev=1674487&r1=1674486&r2=1674487&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/conflict-callbacks.c (original)
+++ subversion/trunk/subversion/svn/conflict-callbacks.c Sat Apr 18 12:14:34 2015
@@ -44,6 +44,9 @@
 #include "svn_private_config.h"
 
 #define ARRAY_LEN(ary) ((sizeof (ary)) / (sizeof ((ary)[0])))
+#define MAX_ARRAY_LEN(aryx, aryz)               \
+  (ARRAY_LEN((aryx)) > ARRAY_LEN((aryz))        \
+   ? ARRAY_LEN((aryx)) : ARRAY_LEN((aryz)))
 
 
 
@@ -709,7 +712,7 @@ handle_text_conflict(svn_wc_conflict_res
      give them a rational basis for choosing (r)esolved? */
   svn_boolean_t knows_something = FALSE;
   const char *local_relpath;
-  
+
   SVN_ERR_ASSERT(desc->kind == svn_wc_conflict_kind_text);
 
   local_relpath = svn_cl__local_style_skip_ancestor(b->path_prefix,
@@ -740,22 +743,17 @@ handle_text_conflict(svn_wc_conflict_res
 
   while (TRUE)
     {
+      const char *options[1 + MAX_ARRAY_LEN(binary_conflict_options,
+                                            text_conflict_options)];
+
       const resolver_option_t *conflict_options = desc->is_binary
                                                     ? binary_conflict_options
                                                     : text_conflict_options;
-      const char **options;
-      const char **next_option;
+      const char **next_option = options;
       const resolver_option_t *opt;
 
       svn_pool_clear(iterpool);
 
-      options = apr_palloc(iterpool,
-                           sizeof (const char *) *
-                           (desc->is_binary
-                              ? ARRAY_LEN(binary_conflict_options)
-                              : ARRAY_LEN(text_conflict_options)));
-      next_option = options;
-
       *next_option++ = "p";
       if (diff_allowed)
         {



Mime
View raw message