Commit e779db8c authored by Tim Peters's avatar Tim Peters

Repaired failure of SetOpTemplate.c to compile (sorry!).

Elsewhere, repaired all other known cases where uses of the
TEST_KEY_OR_SET macro did early exits without finishing persistence
dances (Jeremy confirmed that's a Bad Thing -- creates unghostifiable
cache hogs).
parent 1bebf267
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
****************************************************************************/ ****************************************************************************/
#define BUCKETTEMPLATE_C "$Id: BucketTemplate.c,v 1.31 2002/05/31 14:58:29 tim_one Exp $\n" #define BUCKETTEMPLATE_C "$Id: BucketTemplate.c,v 1.32 2002/06/05 19:26:55 tim_one Exp $\n"
/* /*
** _bucket_get ** _bucket_get
...@@ -41,7 +41,7 @@ _bucket_get(Bucket *self, PyObject *keyarg, int has_key) ...@@ -41,7 +41,7 @@ _bucket_get(Bucket *self, PyObject *keyarg, int has_key)
for (min=0, max=self->len, i=max/2, l=max; i != l; l=i, i=(min+max)/2) for (min=0, max=self->len, i=max/2, l=max; i != l; l=i, i=(min+max)/2)
{ {
TEST_KEY_SET_OR(cmp, self->keys[i], key) return NULL; TEST_KEY_SET_OR(cmp, self->keys[i], key) goto err;
if (PyErr_Occurred()) goto err; if (PyErr_Occurred()) goto err;
if (cmp < 0) min=i; if (cmp < 0) min=i;
...@@ -63,8 +63,11 @@ _bucket_get(Bucket *self, PyObject *keyarg, int has_key) ...@@ -63,8 +63,11 @@ _bucket_get(Bucket *self, PyObject *keyarg, int has_key)
PER_ACCESSED(self); PER_ACCESSED(self);
if (has_key) return PyInt_FromLong(0); if (has_key) return PyInt_FromLong(0);
PyErr_SetObject(PyExc_KeyError, keyarg); PyErr_SetObject(PyExc_KeyError, keyarg);
return NULL;
err: err:
PER_ALLOW_DEACTIVATION(self);
PER_ACCESSED(self);
return NULL; return NULL;
} }
...@@ -161,7 +164,7 @@ _bucket_set(Bucket *self, PyObject *keyarg, PyObject *v, ...@@ -161,7 +164,7 @@ _bucket_set(Bucket *self, PyObject *keyarg, PyObject *v,
for (min=0, max=l=self->len, i=max/2; i != l; l=i, i=(min+max)/2) for (min=0, max=l=self->len, i=max/2; i != l; l=i, i=(min+max)/2)
{ {
TEST_KEY_SET_OR(cmp, self->keys[i], key) return -1; TEST_KEY_SET_OR(cmp, self->keys[i], key) goto err;
if (cmp < 0) min=i; if (cmp < 0) min=i;
else if (cmp==0) else if (cmp==0)
{ {
...@@ -466,7 +469,7 @@ Bucket_findRangeEnd(Bucket *self, PyObject *keyarg, int low, int *offset) ...@@ -466,7 +469,7 @@ Bucket_findRangeEnd(Bucket *self, PyObject *keyarg, int low, int *offset)
for (min=0, max=self->len, i=max/2, l=max; i != l; l=i, i=(min+max)/2) for (min=0, max=self->len, i=max/2, l=max; i != l; l=i, i=(min+max)/2)
{ {
TEST_KEY_SET_OR(cmp, self->keys[i], key) return -1; TEST_KEY_SET_OR(cmp, self->keys[i], key) goto err;
if (cmp < 0) if (cmp < 0)
min=i; min=i;
else if (cmp == 0) else if (cmp == 0)
...@@ -504,8 +507,12 @@ Bucket_findRangeEnd(Bucket *self, PyObject *keyarg, int low, int *offset) ...@@ -504,8 +507,12 @@ Bucket_findRangeEnd(Bucket *self, PyObject *keyarg, int low, int *offset)
PER_ALLOW_DEACTIVATION(self); PER_ALLOW_DEACTIVATION(self);
PER_ACCESSED(self); PER_ACCESSED(self);
return i; return i;
err:
PER_ALLOW_DEACTIVATION(self);
PER_ACCESSED(self);
return -1;
} }
static PyObject * static PyObject *
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
Set operations Set operations
****************************************************************************/ ****************************************************************************/
#define SETOPTEMPLATE_C "$Id: SetOpTemplate.c,v 1.20 2002/06/05 16:03:11 tim_one Exp $\n" #define SETOPTEMPLATE_C "$Id: SetOpTemplate.c,v 1.21 2002/06/05 19:26:55 tim_one Exp $\n"
#ifdef INTSET_H #ifdef INTSET_H
static int static int
...@@ -459,28 +459,29 @@ multiunion_m(PyObject *ignored, PyObject *args) ...@@ -459,28 +459,29 @@ multiunion_m(PyObject *ignored, PyObject *args)
/* If set is a bucket, do a straight resize + memcpy. */ /* If set is a bucket, do a straight resize + memcpy. */
if (set->ob_type == (PyTypeObject*)&SetType || if (set->ob_type == (PyTypeObject*)&SetType ||
set->ob_type == (PyTypeObject*)&BucketType) { set->ob_type == (PyTypeObject*)&BucketType) {
Sized *theset = SIZED(set);
int setsize; int setsize;
int size_desired; int size_desired;
UNLESS (PER_USE(set)) goto Error; UNLESS (PER_USE(theset)) goto Error;
setsize = SIZED(set)->len; setsize = theset->len;
size_desired = result->len + setsize; size_desired = result->len + setsize;
/* If there are more to come, overallocate by 25% (arbitrary). */ /* If there are more to come, overallocate by 25% (arbitrary). */
if (i < n-1) if (i < n-1)
size_desired += size_desired >> 2; size_desired += size_desired >> 2;
if (size_desired && size_desired > result->size) { if (size_desired && size_desired > result->size) {
if (Bucket_grow(result, size_desired, 1) < 0) { if (Bucket_grow(result, size_desired, 1) < 0) {
PER_ALLOW_DEACTIVATION(set); PER_ALLOW_DEACTIVATION(theset);
PER_ACCESSED(set); PER_ACCESSED(theset);
goto Error; goto Error;
} }
} }
memcpy(result->keys + result->len, memcpy(result->keys + result->len,
BUCKET(set)->keys, BUCKET(theset)->keys,
setsize * sizeof(KEY_TYPE)); setsize * sizeof(KEY_TYPE));
result->len += setsize; result->len += setsize;
PER_ALLOW_DEACTIVATION(set); PER_ALLOW_DEACTIVATION(theset);
PER_ACCESSED(set); PER_ACCESSED(theset);
} }
else { else {
/* No cheap way: iterate over set's elements one at a time. */ /* No cheap way: iterate over set's elements one at a time. */
......
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