Re: undefine_c_func (was: memory profiling)
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Nov 20, 2006
- 633 views
On Sun, 19 Nov 2006 15:25:53 -0800, "Michael J. Sabal" <guest at RapidEuphoria.com> wrote: >GTK 2.6 has a procedure that allows for a variable number of arguments, >similar to the way printf does. define_c_proc does not allow for this. My >next thought was to simply define the procedure with the correct number of >arguments each time it's needed. Except, without a matching undefine to >free the memory, we introduce a leak into the library. Why not just store results from define_c_proc in a sequence? Eg:
object xXxxx xXxxx = 0 global procedure Eu_xXxxx(sequence params) integer l atom p l = length(params) if atom(xXxxx) then xXxxx=repeat(0,l) elsif l>length(xXxxx) then xXxxx&=repeat(0,l-length(xXxxx)) end if p = xXxxx[l] if p=0 then p = define_c_proc(lib,"Xxxx",repeat(C_POINTER,l),C_INT) xXxxx[l] = p end if c_proc(p,params) end procedure
Regards, Pete