--------------------- PatchSet 2191 Date: 2001/05/02 20:00:28 Author: akroonmaa Branch: chunked_mempools Tag: (none) Log: clone double_to_str(double) from gb_to_str(gb_t) Members: include/util.h:1.7.16.3->1.7.16.4 lib/util.c:1.7.20.2->1.7.20.3 Index: squid/include/util.h =================================================================== RCS file: /cvsroot/squid-sf//squid/include/util.h,v retrieving revision 1.7.16.3 retrieving revision 1.7.16.4 diff -u -r1.7.16.3 -r1.7.16.4 --- squid/include/util.h 26 Apr 2001 17:13:03 -0000 1.7.16.3 +++ squid/include/util.h 2 May 2001 20:00:28 -0000 1.7.16.4 @@ -1,5 +1,5 @@ /* - * $Id: util.h,v 1.7.16.3 2001/04/26 17:13:03 akroonmaa Exp $ + * $Id: util.h,v 1.7.16.4 2001/05/02 20:00:28 akroonmaa Exp $ * * AUTHOR: Harvest Derived * @@ -139,6 +139,7 @@ #define gb_incb(gb, delta) { if ((gb)->bytes > gb_flush_limit || delta > gb_flush_limit) gb_flush(gb); (gb)->bytes += delta; } #define gb_incc(gb, delta) { if ((gb)->bytes > gb_flush_limit || delta > gb_flush_limit) gb_flush(gb); (gb)->count+= delta; } extern double gb_to_double(const gb_t *); +extern const char *double_to_str(char *buf, int buf_size, double value); extern const char *gb_to_str(const gb_t *); extern void gb_flush(gb_t *); /* internal, do not use this */ Index: squid/lib/util.c =================================================================== RCS file: /cvsroot/squid-sf//squid/lib/util.c,v retrieving revision 1.7.20.2 retrieving revision 1.7.20.3 diff -u -r1.7.20.2 -r1.7.20.3 --- squid/lib/util.c 18 Apr 2001 18:20:22 -0000 1.7.20.2 +++ squid/lib/util.c 2 May 2001 20:00:28 -0000 1.7.20.3 @@ -1,6 +1,6 @@ /* - * $Id: util.c,v 1.7.20.2 2001/04/18 18:20:22 akroonmaa Exp $ + * $Id: util.c,v 1.7.20.3 2001/05/02 20:00:28 akroonmaa Exp $ * * DEBUG: * AUTHOR: Harvest Derived @@ -771,6 +771,19 @@ } const char * +double_to_str(char *buf, int buf_size, double value) +{ + /* select format */ + if (value < 1e9) + snprintf(buf, buf_size, "%.2f MB", value / 1e6); + else if (value < 1e12) + snprintf(buf, buf_size, "%.3f GB", value / 1e9); + else + snprintf(buf, buf_size, "%.4f TB", value / 1e12); + return buf; +} + +const char * gb_to_str(const gb_t * g) { /*