Skip to content

Commit 78beef4

Browse files
committed
introduce constant for string buffer sizes
1 parent 0a0a40f commit 78beef4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/c/perf-map-agent.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
#include "perf-map-file.h"
3333

34+
#define STRING_BUFFER_SIZE 2000
35+
3436
bool unfold_inlined_methods = false;
3537
bool unfold_simple = false;
3638
bool print_method_signatures = false;
@@ -107,7 +109,7 @@ static void sig_string(jvmtiEnv *jvmti, jmethodID method, char *output, size_t n
107109
if (print_method_signatures && msig)
108110
method_signature = msig;
109111

110-
char class_name[2000];
112+
char class_name[STRING_BUFFER_SIZE];
111113
class_name_from_sig(class_name, sizeof(class_name), csig);
112114
snprintf(output, noutput, "%s.%s%s%s", class_name, name, method_signature, source_info);
113115

@@ -119,7 +121,7 @@ static void sig_string(jvmtiEnv *jvmti, jmethodID method, char *output, size_t n
119121
}
120122

121123
void generate_single_entry(jvmtiEnv *jvmti, jmethodID method, const void *code_addr, jint code_size) {
122-
char entry[2000];
124+
char entry[STRING_BUFFER_SIZE];
123125
sig_string(jvmti, method, entry, sizeof(entry));
124126
perf_map_write_entry(method_file, code_addr, code_size, entry);
125127
}
@@ -129,7 +131,7 @@ void generate_unfolded_entry(jvmtiEnv *jvmti, jmethodID method, char *buffer, si
129131
if (unfold_simple)
130132
sig_string(jvmti, method, buffer, buffer_size);
131133
else {
132-
char entry_name[2000];
134+
char entry_name[STRING_BUFFER_SIZE];
133135
sig_string(jvmti, method, entry_name, sizeof(entry_name));
134136
snprintf(buffer, buffer_size, "%s in %s", entry_name, root_name);
135137
}
@@ -144,7 +146,7 @@ void write_unfolded_entry(
144146
const void *start_addr,
145147
const void *end_addr) {
146148
// needs to accommodate: entry_name + " in " + root_name
147-
char inlined_name[2000 * 2 + 4];
149+
char inlined_name[STRING_BUFFER_SIZE * 2 + 4];
148150
const char *entry_p;
149151

150152
if (cur_method != root_method) {
@@ -165,7 +167,7 @@ void generate_unfolded_entries(
165167
const jvmtiAddrLocationMap* map,
166168
const void* compile_info) {
167169
const jvmtiCompiledMethodLoadRecordHeader *header = compile_info;
168-
char root_name[2000];
170+
char root_name[STRING_BUFFER_SIZE];
169171

170172
sig_string(jvmti, root_method, root_name, sizeof(root_name));
171173
if (header->kind == JVMTI_CMLR_INLINE_INFO) {

0 commit comments

Comments
 (0)