开发者

Swig + tcl + c++ (memory managment)

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜