Mercurial > cpython-lru_cache-weakref
diff Modules/structmodule.c @ 36518:9f3f87e920a6 legacy-trunk
Use Py_ssize_t for counts and sizes.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Thu, 16 Feb 2006 14:30:23 +0000 |
| parents | 1af7f719ed28 |
| children | 862493ceae4b |
line wrap: on
line diff
--- a/Modules/structmodule.c Thu Feb 16 14:24:38 2006 +0000 +++ b/Modules/structmodule.c Thu Feb 16 14:30:23 2006 +0000 @@ -1031,7 +1031,7 @@ 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 @@ 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 @@ 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 @@ 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; }
