From 57a022230f9ae1b3f5901e26babafb2d321b4511 Mon Sep 17 00:00:00 2001 From: cgohlke Date: Tue, 14 Jan 2014 21:47:35 -0800 Subject: [PATCH] Fix msvc compile error and improve 64 bit compatibility --- tornado/speedups.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tornado/speedups.c b/tornado/speedups.c index 8a316c582..174a6129e 100644 --- a/tornado/speedups.c +++ b/tornado/speedups.c @@ -1,21 +1,24 @@ +#define PY_SSIZE_T_CLEAN #include static PyObject* websocket_mask(PyObject* self, PyObject* args) { const char* mask; - int mask_len; + Py_ssize_t mask_len; const char* data; - int data_len; - int i; + Py_ssize_t data_len; + Py_ssize_t i; + PyObject* result; + char* buf; if (!PyArg_ParseTuple(args, "s#s#", &mask, &mask_len, &data, &data_len)) { return NULL; } - PyObject* result = PyBytes_FromStringAndSize(NULL, data_len); + result = PyBytes_FromStringAndSize(NULL, data_len); if (!result) { return NULL; } - char* buf = PyBytes_AsString(result); + buf = PyBytes_AsString(result); for (i = 0; i < data_len; i++) { buf[i] = data[i] ^ mask[i % 4]; } -- 2.47.2