Allocating string space
I have many routines in GraphApp.e which use allocate_string(), for example:
global function execapp(sequence cmd)
return c_func(execapp_,{allocate_string(cmd)})
end function --( in c: int execapp(char *cmd) )
Question:
Am I causing major memory leaks?
Does allocate_string allocate a whole new string with a c-style pointer, and if
so, does it free this string once the function is exited?
Would it be better to write this as:
global function execapp(sequence cmd)
atom s
s = allocate_string(cmd)
return c_func(execapp_,{s})
end function
Or like this:
global function execapp(sequence cmd)
atom s
object result
s = allocate_string(cmd)
result = c_func(execapp_,{s})
free(s)
return result
end function
Thanks,
Irv
|
Not Categorized, Please Help
|
|