I use the Swift compiler function to call the C function, which allocates memory using malloc() . Then it returns a pointer to this memory. The prototype of the function is something like:
char *the_function(const char *);
In Swift, I use it as follows:
var ret = the_function(("something" as NSString).UTF8String) let val = String.fromCString(ret)!
Forgive my ignorance regarding Swift, but usually in C, if the_function () is a malloc'ing memory and returns it, someone else needs to free () at some point.
Is this in some way processed by Swift or will I skip memory in this example?
Thanks in advance.
source share