at 15.09-beta 77 lines 1.7 kB view raw
1diff -rc aterm-2.8-orig/aterm/hash.c aterm-2.8/aterm/hash.c 2*** aterm-2.8-orig/aterm/hash.c 2008-11-10 13:54:22.000000000 +0100 3--- aterm-2.8/aterm/hash.c 2009-01-27 18:14:14.000000000 +0100 4*************** 5*** 93,146 **** 6 } 7 8 /*}}} */ 9- /*{{{ static long calc_long_max() */ 10- static long calc_long_max() 11- { 12- long try_long_max; 13- long long_max; 14- long delta; 15- 16- try_long_max = 1; 17- do { 18- long_max = try_long_max; 19- try_long_max = long_max * 2; 20- } while (try_long_max > 0); 21- 22- delta = long_max; 23- while (delta > 1) { 24- while (long_max + delta < 0) { 25- delta /= 2; 26- } 27- long_max += delta; 28- } 29- 30- return long_max; 31- 32- } 33- /*}}} */ 34 /*{{{ static long calculateNewSize(sizeMinus1, nrdel, nrentries) */ 35 36 static long calculateNewSize 37 (long sizeMinus1, long nr_deletions, long nr_entries) 38 { 39- 40- /* Hack: LONG_MAX (limits.h) is often unreliable, we need to find 41- * out the maximum possible value of a signed long dynamically. 42- */ 43- static long st_long_max = 0; 44- 45- /* the resulting length has the form 2^k-1 */ 46- 47 if (nr_deletions >= nr_entries/2) { 48 return sizeMinus1; 49 } 50 51! if (st_long_max == 0) { 52! st_long_max = calc_long_max(); 53! } 54! 55! if (sizeMinus1 > st_long_max / 2) { 56! return st_long_max-1; 57 } 58 59 return (2*sizeMinus1)+1; 60--- 93,109 ---- 61 } 62 63 /*}}} */ 64 /*{{{ static long calculateNewSize(sizeMinus1, nrdel, nrentries) */ 65 66 static long calculateNewSize 67 (long sizeMinus1, long nr_deletions, long nr_entries) 68 { 69 if (nr_deletions >= nr_entries/2) { 70 return sizeMinus1; 71 } 72 73! if (sizeMinus1 > LONG_MAX / 2) { 74! return LONG_MAX-1; 75 } 76 77 return (2*sizeMinus1)+1;