]> mj.ucw.cz Git - libucw.git/commitdiff
Fixed bug in printing of bucket sizes.
authorMartin Mares <mj@ucw.cz>
Fri, 9 Feb 2007 22:58:55 +0000 (23:58 +0100)
committerMartin Mares <mj@ucw.cz>
Fri, 9 Feb 2007 22:58:55 +0000 (23:58 +0100)
lib/sorter/common.h
lib/sorter/govern.c

index 52949657ad411c2face099d6d3b4fd0b4ea85d36..3097ea2de2cdf267a75f63ec13264d573ff18cc9 100644 (file)
@@ -98,9 +98,6 @@ sh_off_t sbuck_size(struct sort_bucket *b);
 struct fastbuf *sbuck_read(struct sort_bucket *b);
 struct fastbuf *sbuck_write(struct sort_bucket *b);
 void sbuck_swap_out(struct sort_bucket *b);
-
-#define F_SIZE(x) ({ byte buf[16]; format_size(buf, x); buf; })
-#define F_BSIZE(b) F_SIZE(sbuck_size(b))
 void format_size(byte *buf, u64 x);
 
 #endif
index 9b8ee774ef6f345531aa21197cf2bd31d6307117..297692c5cde8a957029346870af78f5346ad924f 100644 (file)
 #include <string.h>
 #include <sys/time.h>
 #include <time.h>
+#include <alloca.h>
+
+#define F_SIZE(x) ({ byte *buf = alloca(16); format_size(buf, x); buf; })
+#define F_BSIZE(b) F_SIZE(sbuck_size(b))
 
 static u64
 sorter_clock(void)
@@ -179,7 +183,7 @@ sorter_radix(struct sort_context *ctx, struct sort_bucket *b)
   SORT_XTRACE(2, "Running radix sort on %s with %d bits of %d", F_BSIZE(b), bits, b->hash_bits);
   sorter_start_timer(ctx);
 
-  struct sort_bucket *outs[nbuck];
+  struct sort_bucket **outs = alloca(nbuck * sizeof(struct sort_bucket *));
   for (uns i=nbuck; i--; )
     {
       outs[i] = sbuck_new(ctx);
@@ -189,7 +193,7 @@ sorter_radix(struct sort_context *ctx, struct sort_bucket *b)
 
   ctx->radix_split(ctx, b, outs, b->hash_bits - bits, bits);
 
-  u64 min = ~0U, max = 0, sum = 0;
+  u64 min = ~(u64)0, max = 0, sum = 0;
   for (uns i=0; i<nbuck; i++)
     {
       u64 s = sbuck_size(outs[i]);