src/share/vm/utilities/debug.hpp

changeset 2472
0fa27f37d4d4
parent 2314
f95d63e2154a
child 2497
3582bf76420e
     1.1 --- a/src/share/vm/utilities/debug.hpp	Wed Jan 19 13:04:37 2011 -0800
     1.2 +++ b/src/share/vm/utilities/debug.hpp	Wed Jan 19 19:30:42 2011 -0500
     1.3 @@ -34,6 +34,7 @@
     1.4  class FormatBuffer {
     1.5  public:
     1.6    inline FormatBuffer(const char * format, ...);
     1.7 +  inline void append(const char* format, ...);
     1.8    operator const char *() const { return _buf; }
     1.9  
    1.10  private:
    1.11 @@ -51,6 +52,19 @@
    1.12    va_end(argp);
    1.13  }
    1.14  
    1.15 +template <size_t bufsz>
    1.16 +void FormatBuffer<bufsz>::append(const char* format, ...) {
    1.17 +  // Given that the constructor does a vsnprintf we can assume that
    1.18 +  // _buf is already initialized.
    1.19 +  size_t len = strlen(_buf);
    1.20 +  char* buf_end = _buf + len;
    1.21 +
    1.22 +  va_list argp;
    1.23 +  va_start(argp, format);
    1.24 +  vsnprintf(buf_end, bufsz - len, format, argp);
    1.25 +  va_end(argp);
    1.26 +}
    1.27 +
    1.28  // Used to format messages for assert(), guarantee(), fatal(), etc.
    1.29  typedef FormatBuffer<> err_msg;
    1.30  

mercurial