mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Use string_view instead of char* in CStr ctor
PiperOrigin-RevId: 337045297 Change-Id: If97b405cc2bf1904456bf502fc7d027c7df2ac7a
This commit is contained in:
parent
33bc36ae3d
commit
29e5d03201
|
@ -23,6 +23,7 @@
|
||||||
#include "absl/base/macros.h"
|
#include "absl/base/macros.h"
|
||||||
#include "absl/status/status.h"
|
#include "absl/status/status.h"
|
||||||
#include "absl/strings/str_cat.h"
|
#include "absl/strings/str_cat.h"
|
||||||
|
#include "absl/strings/string_view.h"
|
||||||
#include "sandboxed_api/rpcchannel.h"
|
#include "sandboxed_api/rpcchannel.h"
|
||||||
#include "sandboxed_api/var_abstract.h"
|
#include "sandboxed_api/var_abstract.h"
|
||||||
#include "sandboxed_api/var_pointable.h"
|
#include "sandboxed_api/var_pointable.h"
|
||||||
|
@ -143,8 +144,9 @@ class Array : public Var, public Pointable {
|
||||||
// buffer is owned by the class, and is mutable.
|
// buffer is owned by the class, and is mutable.
|
||||||
class CStr : public Array<char> {
|
class CStr : public Array<char> {
|
||||||
public:
|
public:
|
||||||
explicit CStr(char* cstr) : Array<char>(strlen(cstr) + 1) {
|
explicit CStr(absl::string_view cstr) : Array<char>(cstr.size() + 1) {
|
||||||
std::copy(cstr, cstr + GetNElem(), GetData());
|
std::copy(cstr.begin(), cstr.end(), GetData());
|
||||||
|
GetData()[cstr.size()] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ToString() const final {
|
std::string ToString() const final {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user