32
32
#include " runtime/mutexLocker.hpp"
33
33
#include " runtime/os.hpp"
34
34
35
- LogOutput::~LogOutput () {
36
- os::free (_config_string);
37
- }
38
-
39
35
void LogOutput::describe (outputStream *out) {
40
36
out->print (" %s " , name ());
41
37
out->print_raw (config_string ()); // raw printed because length might exceed O_BUFLEN
@@ -56,34 +52,16 @@ void LogOutput::describe(outputStream *out) {
56
52
}
57
53
58
54
void LogOutput::set_config_string (const char * string) {
59
- os::free (_config_string);
60
- _config_string = os::strdup (string, mtLogging);
61
- _config_string_buffer_size = strlen (_config_string) + 1 ;
55
+ _config_string.reset ();
56
+ _config_string.print_raw (string);
62
57
}
63
58
64
59
void LogOutput::add_to_config_string (const LogSelection& selection) {
65
- if (_config_string_buffer_size < InitialConfigBufferSize) {
66
- _config_string_buffer_size = InitialConfigBufferSize;
67
- _config_string = REALLOC_C_HEAP_ARRAY (char , _config_string, _config_string_buffer_size, mtLogging);
68
- }
69
-
70
- size_t offset = strlen (_config_string);
71
- if (offset > 0 ) {
60
+ if (_config_string.size () > 0 ) {
72
61
// Add commas in-between tag and level combinations in the config string
73
- _config_string[offset++] = ' , ' ;
62
+ _config_string. print_raw ( " , " ) ;
74
63
}
75
-
76
- for (;;) {
77
- int ret = selection.describe (_config_string + offset,
78
- _config_string_buffer_size - offset);
79
- if (ret == -1 ) {
80
- // Double the buffer size and retry
81
- _config_string_buffer_size *= 2 ;
82
- _config_string = REALLOC_C_HEAP_ARRAY (char , _config_string, _config_string_buffer_size, mtLogging);
83
- continue ;
84
- }
85
- break ;
86
- };
64
+ selection.describe_on (&_config_string);
87
65
}
88
66
89
67
0 commit comments