Commit e137d387 authored by Jeremy Hylton's avatar Jeremy Hylton

Remove Py_INCREF and Py_DECREF for objects in doubly linked list.

The cache is intended to keep weak references to objects.  An object
should be deallocated when the only references to it are in the
cache.  If an object is unghostified and added to the list of live
objects, the list should have a borrowed reference.  Otherwise, the
cache will keep the object alive after all other references have
disappeared.
parent ed6b9636
......@@ -14,7 +14,7 @@
static char cPersistence_doc_string[] =
"Defines Persistent mixin class for persistent objects.\n"
"\n"
"$Id: cPersistence.c,v 1.66 2003/04/01 16:08:14 jeremy Exp $\n";
"$Id: cPersistence.c,v 1.67 2003/04/01 17:33:23 jeremy Exp $\n";
#include "cPersistence.h"
......@@ -131,7 +131,6 @@ unghostify(cPersistentObject *self)
self->ring.prev = home->prev;
home->prev->next = &self->ring;
home->prev = &self->ring;
Py_INCREF(self);
}
self->state = cPersistent_CHANGED_STATE;
/* Call the object's __setstate__() */
......@@ -185,14 +184,6 @@ ghostify(cPersistentObject *self)
self->ring.prev = NULL;
self->ring.next = NULL;
self->state = cPersistent_GHOST_STATE;
/* We remove the reference to the just ghosted object that the ring
* holds. Note that the dictionary of oids->objects has an uncounted
* reference, so if the ring's reference was the only one, this frees
* the ghost object. Note further that the object's dealloc knows to
* inform the dictionary that it is going away.
*/
Py_DECREF(self);
}
static void
......
......@@ -14,7 +14,7 @@
static char cPersistence_doc_string[] =
"Defines Persistent mixin class for persistent objects.\n"
"\n"
"$Id: cPersistence.c,v 1.66 2003/04/01 16:08:14 jeremy Exp $\n";
"$Id: cPersistence.c,v 1.67 2003/04/01 17:33:23 jeremy Exp $\n";
#include "cPersistence.h"
......@@ -131,7 +131,6 @@ unghostify(cPersistentObject *self)
self->ring.prev = home->prev;
home->prev->next = &self->ring;
home->prev = &self->ring;
Py_INCREF(self);
}
self->state = cPersistent_CHANGED_STATE;
/* Call the object's __setstate__() */
......@@ -185,14 +184,6 @@ ghostify(cPersistentObject *self)
self->ring.prev = NULL;
self->ring.next = NULL;
self->state = cPersistent_GHOST_STATE;
/* We remove the reference to the just ghosted object that the ring
* holds. Note that the dictionary of oids->objects has an uncounted
* reference, so if the ring's reference was the only one, this frees
* the ghost object. Note further that the object's dealloc knows to
* inform the dictionary that it is going away.
*/
Py_DECREF(self);
}
static void
......
......@@ -14,7 +14,7 @@
static char cPersistence_doc_string[] =
"Defines Persistent mixin class for persistent objects.\n"
"\n"
"$Id: cPersistence.c,v 1.66 2003/04/01 16:08:14 jeremy Exp $\n";
"$Id: cPersistence.c,v 1.67 2003/04/01 17:33:23 jeremy Exp $\n";
#include "cPersistence.h"
......@@ -131,7 +131,6 @@ unghostify(cPersistentObject *self)
self->ring.prev = home->prev;
home->prev->next = &self->ring;
home->prev = &self->ring;
Py_INCREF(self);
}
self->state = cPersistent_CHANGED_STATE;
/* Call the object's __setstate__() */
......@@ -185,14 +184,6 @@ ghostify(cPersistentObject *self)
self->ring.prev = NULL;
self->ring.next = NULL;
self->state = cPersistent_GHOST_STATE;
/* We remove the reference to the just ghosted object that the ring
* holds. Note that the dictionary of oids->objects has an uncounted
* reference, so if the ring's reference was the only one, this frees
* the ghost object. Note further that the object's dealloc knows to
* inform the dictionary that it is going away.
*/
Py_DECREF(self);
}
static void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment