lab.nexedi.com will be down from Thursday, 20 March 2025, 07:30:00 UTC for a duration of approximately 2 hours

Commit 037bc700 authored by chris's avatar chris

fixed memory error

parent 59c87943
...@@ -26,15 +26,13 @@ newWordSequence(PyObject *text, PyObject *synstop, PyObject *wordletters) ...@@ -26,15 +26,13 @@ newWordSequence(PyObject *text, PyObject *synstop, PyObject *wordletters)
{ {
WordSequence *self; WordSequence *self;
PyObject *t; PyObject *t;
PyObject *lower_text;
UNLESS(self = PyObject_NEW(WordSequence, &WordSequenceType)) UNLESS(self = PyObject_NEW(WordSequence, &WordSequenceType))
{ {
return NULL; return NULL;
} }
self->text = text;
Py_INCREF(self->text);
if ((synstop == NULL) || PyDict_Size(synstop) == 0) if ((synstop == NULL) || PyDict_Size(synstop) == 0)
{ {
self->synstop = NULL; self->synstop = NULL;
...@@ -57,18 +55,19 @@ newWordSequence(PyObject *text, PyObject *synstop, PyObject *wordletters) ...@@ -57,18 +55,19 @@ newWordSequence(PyObject *text, PyObject *synstop, PyObject *wordletters)
Py_INCREF(text); Py_INCREF(text);
PyTuple_SET_ITEM((PyTupleObject *)t, 0, text); PyTuple_SET_ITEM((PyTupleObject *)t, 0, text);
UNLESS_ASSIGN(text, PyObject_CallObject(string_lower, t)) UNLESS(lower_text = PyObject_CallObject(string_lower, t))
{ {
Py_DECREF(t); Py_DECREF(t);
return NULL; return NULL;
} }
Py_DECREF(t); Py_DECREF(t);
self->text = lower_text;
self->ctext = self->here = PyString_AsString(lower_text);
self->ctext = self->here = PyString_AsString(text); self->end = self->here + PyString_Size(lower_text);
self->end = self->here + PyString_Size(text);
self->index = -1; self->index = -1;
...@@ -563,8 +562,10 @@ initWordSequence() ...@@ -563,8 +562,10 @@ initWordSequence()
PyObject *m, *string; PyObject *m, *string;
UNLESS(default_wordletters= UNLESS(default_wordletters=
PyString_FromString("abcdefghijklmnopqrstuvwxyz0123456789" PyString_FromString("abcdefghijklmnopqrstuvwxyz0123456789"))
"ABCDEFGHIJKLMNOPQRSTUVWXYZ")) return; {
return;
}
/* Create the module and add the functions */ /* Create the module and add the functions */
m = Py_InitModule4("WordSequence", WordSequence_module_methods, m = Py_InitModule4("WordSequence", WordSequence_module_methods,
......
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