From a1bbe574603d3bf05f47b585ff6c33153b2d7fc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Tue, 19 Oct 2010 19:07:35 +0200 Subject: [PATCH] Fix corner case bug in chunify() --- dedupestore/_speedups.c | 3 +-- dedupestore/chunkifier.py | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/dedupestore/_speedups.c b/dedupestore/_speedups.c index 7b83e4566..657eaf97d 100644 --- a/dedupestore/_speedups.c +++ b/dedupestore/_speedups.c @@ -111,11 +111,10 @@ ChunkifyIter_iternext(PyObject *self) c->window_size); } c->i++; - if(c->i == c->buf_size && c->last == c->window_size - 1) + if(c->i == c->buf_size && c->last == -1) { int old_last = c->last; c->last = c->i - 1; - printf("Max chunk size reached %d\n", c->last - old_last); return PyString_FromStringAndSize((char *)(c->data + old_last + 1), c->last - old_last); } diff --git a/dedupestore/chunkifier.py b/dedupestore/chunkifier.py index d2b7ff6ed..25340a5f1 100644 --- a/dedupestore/chunkifier.py +++ b/dedupestore/chunkifier.py @@ -73,7 +73,7 @@ def next(self): self.data[self.i], self.window_size) self.i += 1 - if self.i == self.buf_size and self.last == self.window_size - 1: + if self.i == self.buf_size and self.last == -1: old_last = self.last self.last = self.i - 1 return self.data[old_last + 1:self.last + 1] diff --git a/setup.py b/setup.py index 4c789f6ba..dfbcd3c61 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ author=u'Jonas Borgström', author_email='jonas@borgstrom.se', packages=['dedupestore'], - ext_modules=[Extension('_speedups', ['dedupestore/_speedups.c'])], + ext_modules=[Extension('dedupestore._speedups', ['dedupestore/_speedups.c'])], entry_points = { 'console_scripts': [ 'dedupestore = dedupestore.archiver:main',