summaryrefslogtreecommitdiffstats
path: root/Modules/structmodule.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-02-16 14:30:23 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2006-02-16 14:30:23 (GMT)
commitad0a4629beac0600c4c4c3167b0d68be57ca674e (patch)
treea4aef28fd7dbf93c7dabde51ce88fe1748e29427 /Modules/structmodule.c
parent97c65a8068056863215eb3a14024c1e4a8d19b9f (diff)
downloadcpython-ad0a4629beac0600c4c4c3167b0d68be57ca674e.zip
cpython-ad0a4629beac0600c4c4c3167b0d68be57ca674e.tar.gz
cpython-ad0a4629beac0600c4c4c3167b0d68be57ca674e.tar.bz2
Use Py_ssize_t for counts and sizes.
Diffstat (limited to 'Modules/structmodule.c')
-rw-r--r--Modules/structmodule.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/Modules/structmodule.c b/Modules/structmodule.c
index f07f21a..2fa6e90 100644
--- a/Modules/structmodule.c
+++ b/Modules/structmodule.c
@@ -1031,7 +1031,7 @@ struct_pack(PyObject *self, PyObject *args)
PyObject *format, *result, *v;
char *fmt;
int size, num;
- int i, n;
+ Py_ssize_t i, n;
char *s, *res, *restart, *nres;
char c;
@@ -1097,7 +1097,7 @@ struct_pack(PyObject *self, PyObject *args)
goto fail;
if (c == 's') {
/* num is string size, not repeat count */
- int n;
+ Py_ssize_t n;
if (!PyString_Check(v)) {
PyErr_SetString(StructError,
"argument for 's' must be a string");
@@ -1116,7 +1116,7 @@ struct_pack(PyObject *self, PyObject *args)
else if (c == 'p') {
/* num is string size + 1,
to fit in the count byte */
- int n;
+ Py_ssize_t n;
num--; /* now num is max string size */
if (!PyString_Check(v)) {
PyErr_SetString(StructError,
@@ -1133,7 +1133,8 @@ struct_pack(PyObject *self, PyObject *args)
memset(res+1+n, '\0', num-n);
if (n > 255)
n = 255;
- *res++ = n; /* store the length byte */
+ /* store the length byte */
+ *res++ = Py_SAFE_DOWNCAST(n, Py_ssize_t, char);
res += num;
break;
}