mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-05 11:30:47 -05:00
Make Utf8CStr a first class citizen in C++ codebase
Utf8CStr is in many cases a better string view class than std::string_view, because it provides "view" access to a string buffer that is guaranteed to be null terminated. It also has the additional benefit of being UTF-8 verified and can seemlessly cross FFI boundaries. We would want to start use more Utf8CStr in our existing C++ codebase.
This commit is contained in:
@@ -97,7 +97,7 @@ SePolicy SePolicy::from_data(rust::Slice<const uint8_t> data) noexcept {
|
||||
return {std::make_unique<sepol_impl>(db)};
|
||||
}
|
||||
|
||||
SePolicy SePolicy::from_file(::rust::Utf8CStr file) noexcept {
|
||||
SePolicy SePolicy::from_file(::Utf8CStr file) noexcept {
|
||||
LOGD("Load policy from: %.*s\n", static_cast<int>(file.size()), file.data());
|
||||
|
||||
policy_file_t pf;
|
||||
@@ -235,7 +235,7 @@ static int vec_write(void *v, const char *buf, int len) {
|
||||
return len;
|
||||
}
|
||||
|
||||
bool SePolicy::to_file(::rust::Utf8CStr file) const noexcept {
|
||||
bool SePolicy::to_file(::Utf8CStr file) const noexcept {
|
||||
// No partial writes are allowed to /sys/fs/selinux/load, thus the reason why we
|
||||
// first dump everything into memory, then directly call write system call
|
||||
vector<char> out;
|
||||
|
||||
Reference in New Issue
Block a user