This is an automated email from the ASF dual-hosted git repository.
kichan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 4704ee4945 Properly handle string return from function (#11442)
4704ee4945 is described below
commit 4704ee494572305dbfdb5edddc1495b8a0c88d4c
Author: Kit Chan <[email protected]>
AuthorDate: Sun Jun 16 11:41:35 2024 -0700
Properly handle string return from function (#11442)
* Properly handle string return from function
* Update ats_context.h
* Update ats_context.h
* Update ats_context.h
---
plugins/experimental/wasm/ats_context.h | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/plugins/experimental/wasm/ats_context.h
b/plugins/experimental/wasm/ats_context.h
index 0574b42ec4..094a654c25 100644
--- a/plugins/experimental/wasm/ats_context.h
+++ b/plugins/experimental/wasm/ats_context.h
@@ -180,10 +180,10 @@ public:
return this;
}
- std::string
- get()
+ const char *
+ getDataStrPtr()
{
- return owned_data_str_;
+ return owned_data_str_.c_str();
}
private:
@@ -276,9 +276,12 @@ public:
const char *
getTransformResult(size_t *body_size)
{
- std::string s = transform_result_.get();
- *body_size = s.size();
- return s.c_str();
+ if (body_size != nullptr) {
+ *body_size = transform_result_.size();
+ return transform_result_.getDataStrPtr();
+ } else {
+ return nullptr;
+ }
}
// Metrics