summaryrefslogtreecommitdiff
path: root/base/HidlSupport.cpp
diff options
context:
space:
mode:
authorSteven Moreland <smoreland@google.com>2017-02-16 09:23:45 -0800
committerSteven Moreland <smoreland@google.com>2017-02-16 19:17:31 +0000
commita21d84f11f066315bd1476368d511286d129cb8a (patch)
tree13e0f3afcb956fccaf899e0c3a1ee835a8b8cc56 /base/HidlSupport.cpp
parenteba5145c8c4b7ad344bd277616d24dc20343a90f (diff)
downloadlibhidl-a21d84f11f066315bd1476368d511286d129cb8a.tar.gz
hidl_string: allow null cstr
Automatically converting nullptr to empty string rather than erroring. This gets rid of null values at the hal layer (rather than passing them to the server) and simplifies code that would have to check for nulls. Test: libhidl_test Fixes: 35421240 Change-Id: Iada25da5407c3eccdd28704d993ffdee8b15c5fe
Diffstat (limited to 'base/HidlSupport.cpp')
-rw-r--r--base/HidlSupport.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/base/HidlSupport.cpp b/base/HidlSupport.cpp
index 1544969..68155cd 100644
--- a/base/HidlSupport.cpp
+++ b/base/HidlSupport.cpp
@@ -195,6 +195,10 @@ hidl_string::~hidl_string() {
}
hidl_string::hidl_string(const char *s) : hidl_string() {
+ if (s == nullptr) {
+ return;
+ }
+
copyFrom(s, strlen(s));
}