ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/cfperl.xs
(Generate patch)

Comparing deliantra/server/server/cfperl.xs (file contents):
Revision 1.154 by root, Fri Jan 26 21:44:11 2007 UTC vs.
Revision 1.155 by root, Fri Jan 26 22:06:30 2007 UTC

112{ 112{
113 return refcnt + (self ? SvREFCNT (self) - 1 : 0); 113 return refcnt + (self ? SvREFCNT (self) - 1 : 0);
114} 114}
115 115
116void 116void
117attachable::sever_self ()
118{
119 if (HV *self = this->self)
120 {
121 // keep a refcount because sv_unmagic might call attachable_free,
122 // which might clear self, causing sv_unmagic to crash on a now
123 // invalid object.
124 SvREFCNT_inc (self);
125 hv_clear (self);
126 sv_unmagic ((SV *)self, PERL_MAGIC_ext);
127 SvREFCNT_dec (self);
128
129 // self *must* be null now because thats sv_unmagic's job.
130 assert (!this->self);
131 }
132}
133
134void
117attachable::optimise () 135attachable::optimise ()
118{ 136{
119 if (self 137 if (self
120 && SvREFCNT (self) == 1 138 && SvREFCNT (self) == 1
121 && !HvTOTALKEYS (self)) 139 && !HvTOTALKEYS (self))
122 { 140 sever_self ();
123 SV *self = (SV *)this->self;
124
125 SvREFCNT_inc (self);
126 sv_unmagic (self, PERL_MAGIC_ext);
127 SvREFCNT_dec (self);
128 assert (!this->self);
129 }
130} 141}
131 142
132// check wether the object really is dead 143// check wether the object really is dead
133void 144void
134attachable::do_check () 145attachable::do_check ()
149 SvREFCNT_dec (cb); 160 SvREFCNT_dec (cb);
150 cb = 0; 161 cb = 0;
151 } 162 }
152 163
153 if (self) 164 if (self)
154 { 165 sever_self ();
155 hv_clear (self);
156
157 SV *self = (SV *)this->self;
158 SvREFCNT_inc (self);
159 sv_unmagic (self, PERL_MAGIC_ext);
160 SvREFCNT_dec (self);
161 // self is now 0
162 assert (!this->self);//D//TODO remove soon
163 }
164 166
165 mortals.push_back (this); 167 mortals.push_back (this);
166} 168}
167 169
168void 170void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines