Store struct termios used by POSIX::Termios directly in the object SV.
authorNicholas Clark <nick@ccl4.org>
Wed, 7 Sep 2011 11:15:04 +0000 (13:15 +0200)
committerNicholas Clark <nick@ccl4.org>
Tue, 13 Sep 2011 09:28:07 +0000 (11:28 +0200)
commit11a39fe4420c9bcf095e8bb586946eb66cfa2aec
treecd7f81620298ecb492943a6a191d1b0f9db8c696
parent8f8f11b514b019e5fda484221d756dd4d736b93b
Store struct termios used by POSIX::Termios directly in the object SV.

Previously POSIX::Termios was using the PTROBJ typemap to store a pointer to
a dynamically-allocated struct termios as an IV (blessed into the class).
This requires an explicit DESTROY to free the dynamic allocation, but fails
badly if any POSIX::Termios objects exist at ithread clone time, as the
dynamic allocation is not duplicated in the new thread. (DESTROY is called
in both threads, free-from-wrong pool or other jollity occurs.)

Removing dynamic allocation removes the need for a DESTROY method.

This introduces a new OPAQUEPTROBJ typemap, but currently doesn't use the
OUTPUT section, as that copies an existing structure, whereas
POSIX::Termios->new() only needs to zero-allocate the right space. Assuming
that this typemap should be of general applicability, it should be moved to
the main typemap file.
ext/POSIX/POSIX.xs
ext/POSIX/typemap