Skip to content

Commit 2cea382

Browse files
committed
Remove string frees to support GetUTFRegion transition
Removed string free calls from tracing SDK now obsolete with the move from GetUTFStringChars to GetUTFRegion in the JNI string handling. The higher level code (JNI) never owns memory unless it's explicitly copied into a string for instance. This makes memory management simpler and provides some performance opportunities in the caller. Test: atest PerfettoTest Bug: 303199244 Flag: android.os.perfetto_sdk_tracing_v2 Change-Id: I495cd593f04e7444527b567bc7efddfe0cd92f71
1 parent ae03cf1 commit 2cea382

1 file changed

Lines changed: 0 additions & 30 deletions

File tree

libs/tracing_perfetto/include/tracing_sdk.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,8 @@ class DebugArg {
292292
arg_ = std::move(arg);
293293
}
294294

295-
~DebugArg() {
296-
free_string_value();
297-
}
298-
299295
void set_value(T value) {
300296
if constexpr (std::is_same_v<T, const char*>) {
301-
free_string_value();
302297
arg_.value = value;
303298
} else if constexpr (std::is_same_v<T, int64_t>) {
304299
arg_.value = value;
@@ -321,16 +316,6 @@ class DebugArg {
321316
DISALLOW_COPY_AND_ASSIGN(DebugArg);
322317
TypeMap::type arg_;
323318
const std::string name_;
324-
325-
constexpr void free_string_value() {
326-
if constexpr (std::is_same_v<typename TypeMap::type,
327-
PerfettoTeHlExtraDebugArgString>) {
328-
if (arg_.value) {
329-
free((void*)arg_.value);
330-
arg_.value = nullptr;
331-
}
332-
}
333-
}
334319
};
335320

336321
template <typename T>
@@ -375,10 +360,6 @@ class ProtoField {
375360
arg_ = std::move(arg);
376361
}
377362

378-
~ProtoField() {
379-
free_string_value();
380-
}
381-
382363
void set_value(uint32_t id, T value) {
383364
if constexpr (std::is_same_v<T, int64_t>) {
384365
arg_.header.id = id;
@@ -387,7 +368,6 @@ class ProtoField {
387368
arg_.header.id = id;
388369
arg_.value = value;
389370
} else if constexpr (std::is_same_v<T, const char*>) {
390-
free_string_value();
391371
arg_.header.id = id;
392372
arg_.str = value;
393373
}
@@ -404,16 +384,6 @@ class ProtoField {
404384
private:
405385
DISALLOW_COPY_AND_ASSIGN(ProtoField);
406386
TypeMap::type arg_;
407-
408-
constexpr void free_string_value() {
409-
if constexpr (std::is_same_v<typename TypeMap::type,
410-
PerfettoTeHlProtoFieldCstr>) {
411-
if (arg_.str) {
412-
free((void*)arg_.str);
413-
arg_.str = nullptr;
414-
}
415-
}
416-
}
417387
};
418388

419389
class ProtoFieldNested {

0 commit comments

Comments
 (0)