Cleanup: Use std::string for WM API function return values

This commit is contained in:
Hans Goudey
2024-01-29 16:33:06 -05:00
parent 4fa780d334
commit 61fb2b17c8
10 changed files with 174 additions and 204 deletions

View File

@@ -313,7 +313,6 @@ static PyObject *pyop_as_string(PyObject * /*self*/, PyObject *args)
bool macro_args = true;
int error_val = 0;
char *buf = nullptr;
PyObject *pybuf;
bContext *C = BPY_context_get();
@@ -370,8 +369,9 @@ static PyObject *pyop_as_string(PyObject * /*self*/, PyObject *args)
&ptr, kw, false, "Converting py args to operator properties: ");
}
std::string op_string;
if (error_val == 0) {
buf = WM_operator_pystring_ex(C, nullptr, all_args, macro_args, ot, &ptr);
op_string = WM_operator_pystring_ex(C, nullptr, all_args, macro_args, ot, &ptr);
}
WM_operator_properties_free(&ptr);
@@ -380,9 +380,8 @@ static PyObject *pyop_as_string(PyObject * /*self*/, PyObject *args)
return nullptr;
}
if (buf) {
pybuf = PyUnicode_FromString(buf);
MEM_freeN(buf);
if (!op_string.empty()) {
pybuf = PyUnicode_FromString(op_string.c_str());
}
else {
pybuf = PyUnicode_FromString("");