Browse Source

prototype: pEp::String - avoid nullptr in the char* (if the c_str_p is nullptr then init with "")

heck-rework
heck 3 years ago
parent
commit
33b898fa23
  1. 14
      test/test_nr1.cc

14
test/test_nr1.cc

@ -204,6 +204,11 @@ namespace pEp {
_is_bound = true; _is_bound = true;
pEpLogClass(to_string()); pEpLogClass(to_string());
set_owner(is_owner); set_owner(is_owner);
//if the c_str_p is nullptr then init with ""
if (*_c_str_pp == nullptr) {
this->operator=("");
}
} }
~String() ~String()
@ -225,14 +230,7 @@ namespace pEp {
_free(); _free();
// ALLOCATION // ALLOCATION
if (str.empty()) { *_c_str_pp = _copy(str);
// if the new value is empty str, lets point to nothing
*_c_str_pp = nullptr;
_c_str_p = *_c_str_pp;
} else {
*_c_str_pp = pEp::alloc_str(str);
_c_str_p = *_c_str_pp;
}
pEpLogClass("After: " + to_string()); pEpLogClass("After: " + to_string());
return *this; return *this;
} }

Loading…
Cancel
Save