summaryrefslogtreecommitdiffstats
path: root/Modules/_tracemalloc.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-12-16 22:05:13 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-12-16 22:05:13 (GMT)
commit4d8c29cd572b9556e6cfdcfea58724c4a69dbaa6 (patch)
tree4345acad5e5f796a676e45ac3ea2e9190cb5330c /Modules/_tracemalloc.c
parentfffb96ba66ab46c2de48e228d69ab10a19b1ea2d (diff)
downloadcpython-4d8c29cd572b9556e6cfdcfea58724c4a69dbaa6.zip
cpython-4d8c29cd572b9556e6cfdcfea58724c4a69dbaa6.tar.gz
cpython-4d8c29cd572b9556e6cfdcfea58724c4a69dbaa6.tar.bz2
tracemalloc: only use unsigned types to compute hash
Commit to simplify the backport to python 2.7 and to make the code more consistent.
Diffstat (limited to 'Modules/_tracemalloc.c')
-rw-r--r--Modules/_tracemalloc.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c
index 95b05d6..7e6113d 100644
--- a/Modules/_tracemalloc.c
+++ b/Modules/_tracemalloc.c
@@ -336,8 +336,7 @@ static Py_uhash_t
traceback_hash(traceback_t *traceback)
{
/* code based on tuplehash() of Objects/tupleobject.c */
- Py_uhash_t x; /* Unsigned for defined overflow behavior. */
- Py_hash_t y;
+ Py_uhash_t x, y; /* Unsigned for defined overflow behavior. */
int len = traceback->nframe;
Py_uhash_t mult = _PyHASH_MULTIPLIER;
frame_t *frame;
@@ -345,13 +344,13 @@ traceback_hash(traceback_t *traceback)
x = 0x345678UL;
frame = traceback->frames;
while (--len >= 0) {
- y = PyObject_Hash(frame->filename);
- y ^= frame->lineno;
+ y = (Py_uhash_t)PyObject_Hash(frame->filename);
+ y ^= (Py_uhash_t)frame->lineno;
frame++;
x = (x ^ y) * mult;
/* the cast might truncate len; that doesn't change hash stability */
- mult += (Py_hash_t)(82520UL + len + len);
+ mult += (Py_uhash_t)(82520UL + len + len);
}
x += 97531UL;
return x;