Commit Graph

13 Commits

Author SHA1 Message Date
James Turk 17dd9a626f fix for damerau on Py3 2015-02-04 12:16:17 -05:00
James Turk 7cec95fa13 Merge pull request #31 from dparrol/mra_fixes
Fix a memory leak (and simplify memory handling) in mra.c
2015-02-04 11:03:17 -05:00
Danrich Parrol 39d34bc252 Fix potential memory leak.
If s1_codex fails but s2_codex succeeds, we don't want to leak the
memory allocated to hold s2_codex. Ideally, we want to bail out before
computing s2_codex at all.

Actually, this patch does a bit more than that; it factors out the act
of computing a match rating codex and switches over to using
stack-allocated buffers where possible. This simplifies the memory
handling, shortens the code, and probably provides an insignificant
speedup.
2015-02-03 22:28:04 -08:00
Danrich Parrol b9bbb0d450 Fix segfault in Damerau-Levenstein C code.
If one of the characters had a value of 128 or above, this would be
treated as a signed char and would result in an array lookup with a
negative index. The somewhat contrived test case given here --
comparing a space with a non-breaking space -- reproduces the
segmentation fault prior to the fix.

This also makes a Clang warning go away. Thanks, compiler! :-)
2015-02-03 22:04:23 -08:00
Danrich Parrol 77df97b59b Fix potential memory leak.
If the second memory allocation fails, then we need to free the first.
While we're at it, the zeroing of allocated memory can be replaced by
a call to calloc().
2015-02-03 22:02:04 -08:00
James Turk 81e0d44646 C version of damerau 2014-11-19 00:17:08 -05:00
David McKean f5a907c4de Changed jaro-winkler to only perform winkler step if both strings are at least 4 characters long 2014-07-24 16:19:27 -06:00
James Turk 83053b918b more compilation C90 errors 2014-05-01 00:31:47 -04:00
James Turk e160c28657 fix C90 warning in mra 2014-05-01 00:27:51 -04:00
James Turk 48f70ce4cd remove semicolon 2014-05-01 00:24:12 -04:00
James Turk 9a172611c1 maybe make C pkg importable 2014-03-14 21:29:18 -04:00
James Turk ba0619141f merge the nasty setup.py stuff 2014-03-14 20:08:25 -04:00
James Turk c41696f2bb move things around and change setup.py 2013-04-18 01:09:56 -04:00