mirror of
https://github.com/protocolbuffers/protobuf
synced 2026-08-26 02:23:14 -04:00
Besides unnecessary inconsistency on our C symbols, double underscores anywhere in the name are reserved for stdlib use. In practice its unlikely these symbols would ever hit a collision problem (maybe the prior name 'utf8_debug_string' with no prefix as having some risk), but safer to just standardize on this and have no concerns going forward. PiperOrigin-RevId: 648709299
26 lines
557 B
C++
26 lines
557 B
C++
#include "rust/cpp_kernel/strings.h"
|
|
|
|
#include <cstring>
|
|
#include <string>
|
|
|
|
#include "rust/cpp_kernel/rust_alloc_for_cpp_api.h"
|
|
|
|
namespace google {
|
|
namespace protobuf {
|
|
namespace rust_internal {
|
|
|
|
RustStringRawParts::RustStringRawParts(std::string src) {
|
|
if (src.empty()) {
|
|
data = nullptr;
|
|
len = 0;
|
|
} else {
|
|
void* d = rust_proto_alloc(src.length(), 1);
|
|
std::memcpy(d, src.data(), src.length());
|
|
data = static_cast<char*>(d);
|
|
len = src.length();
|
|
}
|
|
}
|
|
|
|
} // namespace rust_internal
|
|
} // namespace protobuf
|
|
} // namespace google
|