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.151 by root, Tue Jan 23 01:29:51 2007 UTC vs.
Revision 1.152 by root, Tue Jan 23 03:17:56 2007 UTC

107} 107}
108 108
109int 109int
110attachable::refcnt_cnt () const 110attachable::refcnt_cnt () const
111{ 111{
112 return refcnt + (self ? SvREFCNT (self) : 0); 112 return refcnt + (self ? SvREFCNT (self) - 1 : 0);
113} 113}
114 114
115void 115void
116attachable::optimise () 116attachable::optimise ()
117{ 117{
118 if (self 118 if (self
119 && SvREFCNT (self) == 1 119 && SvREFCNT (self) == 1
120 && !HvTOTALKEYS (self)) 120 && !HvTOTALKEYS (self))
121 { 121 {
122 refcnt_inc ();
123 SvREFCNT_dec ((SV *)self); 122 SvREFCNT_dec ((SV *)self);
123 assert (!self);
124 } 124 }
125} 125}
126 126
127// check wether the object really is dead 127// check wether the object really is dead
128void 128void
129attachable::do_check () 129attachable::do_check ()
130{ 130{
131 if (refcnt > 0 || refcnt_cnt () > 0) 131 if (refcnt_cnt () > 0)
132 return; 132 return;
133 133
134 destroy (); 134 destroy ();
135 135
136 if (self) 136 if (self)
173 if (i >= mortals.size ()) 173 if (i >= mortals.size ())
174 { 174 {
175 i = 0; 175 i = 0;
176 176
177 if (mortals.size () > 1000) 177 if (mortals.size () > 1000)
178 fprintf (stderr, "mortal queue size (%d) exceeds 1000.\n", mortals.size ()); 178 fprintf (stderr, "mortal queue size (%d) exceeds 1000.\n", (int)mortals.size ());
179 179
180 break; 180 break;
181 } 181 }
182 182
183 attachable *obj = mortals [i]; 183 attachable *obj = mortals [i];
245 245
246 if (!obj->self) 246 if (!obj->self)
247 { 247 {
248 obj->self = newHV (); 248 obj->self = newHV ();
249 sv_magicext ((SV *)obj->self, 0, PERL_MAGIC_ext, &attachable::vtbl, (char *)obj, 0); 249 sv_magicext ((SV *)obj->self, 0, PERL_MAGIC_ext, &attachable::vtbl, (char *)obj, 0);
250
251 // borrow the refcnt from the object
252 // it is important thta no refcnt_chk is being executed here
253 obj->refcnt_dec ();
254 250
255 // now bless the object _once_ 251 // now bless the object _once_
256 return sv_bless (newRV_inc ((SV *)obj->self), stash); 252 return sv_bless (newRV_inc ((SV *)obj->self), stash);
257 } 253 }
258 else 254 else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines