开发者

Swig + tcl + c++ (memory managment)

开发者 https://www.devze.com 2023-03-11 14:52 出处:网络
I have a procedure in tcl that again call a c++ method using interface created by swig. The procedure returns a list of pointers. I开发者_JAVA百科 checked ownership for a single element in the List in

I have a procedure in tcl that again call a c++ method using interface created by swig. The procedure returns a list of pointers. I开发者_JAVA百科 checked ownership for a single element in the List in tcl using

[lindex $listname 0] cget -thisown

it returns 0 instead of 1.


According to the SWIG documentation on memory management, pointers aren't owned by (the SWIG binding to) Tcl by default. If SWIG has got it wrong, use the -acquire/-disown operations to correct it. For example:

[lindex $listname 0] -acquire

Be careful! Getting memory management wrong will lead to confusing crashes or memory leaks.

0

精彩评论

暂无评论...
验证码 换一张
取 消