Streamline and improve std::string typemaps
Avoid unnecessary heap allocations, just use temporary variables. Actually update the string parameters passed by pointer/non-const reference. This requires the pointers passed to actually be non-const, so update the C-specific unit test runme to use a char buffer instead of a literal string. Also simplify the code copying the string contents to just use strdup() (if there are ever any platforms where this POSIX functions is not available, we could just define it ourselves once instead of using strlen() + malloc() + memcpy() manually twice).
This commit is contained in:
parent
628e2cf6d2
commit
aacc930023
2 changed files with 49 additions and 38 deletions
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
int main()
|
||||
{
|
||||
char *myComposedString = c_backend_cpp_natural_std_string_myStringAppend("World, ", "Hello!");
|
||||
char buf[] = "World, ";
|
||||
char *myComposedString = c_backend_cpp_natural_std_string_myStringAppend(buf, "Hello!");
|
||||
|
||||
assert(myComposedString);
|
||||
assert(strcmp(myComposedString, "World, Hello!") == 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue