]> granicus.if.org Git - graphviz/commitdiff
sfdpgen check_int_array_size: abbreviate no-op 'MAX' call
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 28 Aug 2022 20:14:16 +0000 (13:14 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 31 Aug 2022 00:12:49 +0000 (17:12 -0700)
1b847b5abf50d2ab0701523b90a20306d0ee5528 seems to have incorrectly assumed
multiplication has a higher precedence than casts. In reality, it is the
opposite, meaning the first parameter to this `MAX` call was always 0. So the
entire expression would evaluate to 10. Empirically this seems to have been fine
since this code has been in use for over a decade with no specific problems
blamed on this area. So lets just abbreviate it into what it evaluates to.

Gitlab: #2269

lib/sfdpgen/spring_electrical.c

index e7e87cd207f9829a93e2f23b8dd8f4bb9488d032..a9c56b366f408024233d2e03b95518f77a69129b 100644 (file)
@@ -315,7 +315,7 @@ static void check_real_array_size(double **a, int len, int *lenmax){
 }
 static void check_int_array_size(int **a, int len, int *lenmax){
   if (len >= *lenmax){
-    *lenmax = len + MAX((int) 0.2*len, 10);
+    *lenmax = len + 10;
     *a = REALLOC(*a, sizeof(int)*(*lenmax));
   }