A counterpart to apr_itoa(), so that we can eliminate some inefficient 'sprintf(foo, "%u", bar)' calls in the httpd.
Index: srclib/apr/include/apr_strings.h =================================================================== RCS file: /home/cvspublic/apr/include/apr_strings.h,v retrieving revision 1.23 diff -u -r1.23 apr_strings.h --- srclib/apr/include/apr_strings.h 2001/12/02 09:20:23 1.23 +++ srclib/apr/include/apr_strings.h 2001/12/26 09:14:54 @@ -298,6 +298,14 @@ APR_DECLARE(char *) apr_itoa(apr_pool_t *p, int n);
/** + * create a string representation of an unsigned int, allocated from a pool + * @param p The pool from which to allocate + * @param n The number to format + * @return The string representation of the number + */ +APR_DECLARE(char *) apr_utoa(apr_pool_t *p, unsigned n); + +/** * create a string representation of a long, allocated from a pool * @param p The pool from which to allocate * @param n The number to format Index: srclib/apr/strings/apr_strings.c =================================================================== RCS file: /home/cvspublic/apr/strings/apr_strings.c,v retrieving revision 1.23 diff -u -r1.23 apr_strings.c --- srclib/apr/strings/apr_strings.c 2001/12/02 09:20:23 1.23 +++ srclib/apr/strings/apr_strings.c 2001/12/26 09:14:54 @@ -215,6 +215,19 @@ return start; }
+APR_DECLARE(char *) apr_utoa(apr_pool_t *p, unsigned n) +{ + const int BUFFER_SIZE = sizeof(unsigned) * 3 + 2; + char *buf = apr_palloc(p, BUFFER_SIZE); + char *start = buf + BUFFER_SIZE - 1; + *start = 0; + do { + *--start = '0' + (n % 10); + n /= 10; + } while (n); + return start; +} + APR_DECLARE(char *) apr_ltoa(apr_pool_t *p, long n) { const int BUFFER_SIZE = sizeof(long) * 3 + 2;