summaryrefslogtreecommitdiffstats
path: root/Modules/_collectionsmodule.c
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2015-03-01 07:29:16 (GMT)
committerRaymond Hettinger <python@rcn.com>2015-03-01 07:29:16 (GMT)
commitc20830804df99535b5566e93a4e56afd16cf0e99 (patch)
treed0108ca8bcad15b21d7c21f42db114cda31e1273 /Modules/_collectionsmodule.c
parente4969f5df832eb8f626544d38ee11b75b52b4aee (diff)
downloadcpython-c20830804df99535b5566e93a4e56afd16cf0e99.zip
cpython-c20830804df99535b5566e93a4e56afd16cf0e99.tar.gz
cpython-c20830804df99535b5566e93a4e56afd16cf0e99.tar.bz2
Need a (size_t) cast instead of (unsigned) to be big enough for a Py_ssize_t.
Diffstat (limited to 'Modules/_collectionsmodule.c')
-rw-r--r--Modules/_collectionsmodule.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index 908cfd2..0ca9be1 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -1,6 +1,12 @@
#include "Python.h"
#include "structmember.h"
+#ifdef STDC_HEADERS
+#include <stddef.h>
+#else
+#include <sys/types.h> /* For size_t */
+#endif
+
/* collections module implementation of a deque() datatype
Written and maintained by Raymond D. Hettinger <python@rcn.com>
Copyright (c) 2004-2015 Python Software Foundation.
@@ -780,15 +786,15 @@ deque_item(dequeobject *deque, Py_ssize_t i)
b = deque->rightblock;
} else {
i += deque->leftindex;
- n = (Py_ssize_t)((unsigned) i / BLOCKLEN);
- i = (Py_ssize_t)((unsigned) i % BLOCKLEN);
+ n = (Py_ssize_t)((size_t) i / BLOCKLEN);
+ i = (Py_ssize_t)((size_t) i % BLOCKLEN);
if (index < (Py_SIZE(deque) >> 1)) {
b = deque->leftblock;
while (n--)
b = b->rightlink;
} else {
n = (Py_ssize_t)(
- ((unsigned)(deque->leftindex + Py_SIZE(deque) - 1))
+ ((size_t)(deque->leftindex + Py_SIZE(deque) - 1))
/ BLOCKLEN - n);
b = deque->rightblock;
while (n--)
@@ -839,15 +845,15 @@ deque_ass_item(dequeobject *deque, Py_ssize_t i, PyObject *v)
return deque_del_item(deque, i);
i += deque->leftindex;
- n = (Py_ssize_t)((unsigned) i / BLOCKLEN);
- i = (Py_ssize_t)((unsigned) i % BLOCKLEN);
+ n = (Py_ssize_t)((size_t) i / BLOCKLEN);
+ i = (Py_ssize_t)((size_t) i % BLOCKLEN);
if (index <= halflen) {
b = deque->leftblock;
while (n--)
b = b->rightlink;
} else {
n = (Py_ssize_t)(
- ((unsigned)(deque->leftindex + Py_SIZE(deque) - 1))
+ ((size_t)(deque->leftindex + Py_SIZE(deque) - 1))
/ BLOCKLEN - n);
b = deque->rightblock;
while (n--)