hello all,

is it allowed/possible to allocate some memory in a c++ class like this:

class Myclass {
        private:
        double *buf;
        public:
        Myclass( int n ) { buf = new double[n]; }
        ~Myclass() { delete[] buf; }
};
        
in the perl xs system? ive tried this, and the _new_ statement in the 
constructor works, but the destructor (actually, the DESTROY method of the 
perl package) seems to be called twice which violates segmentation; the _buf_ 
pointer is delete[]ed twice.

my typemap stems from Dean Roehrich's CookBookA (thx), and the xs file only 
holds these two methods:

Myclass *
Myclass::new( n )
int n

void
Myclass::DESTROY()

the Myclass * is typemapped to O_OBJECT. 

maybe theres something wrong with the reference counts?

im very grateful for any help.
greetings,

ludwig



Reply via email to