Skip to content

Commit

Permalink
Merge pull request tornadoweb#973 from cgohlke/patch-1
Browse files Browse the repository at this point in the history
Fix msvc compile error and improve 64 bit compatibility
  • Loading branch information
bdarnell committed Jan 16, 2014
2 parents 0e1a830 + 57a0222 commit 21d6cde
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tornado/speedups.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>

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];
}
Expand Down

0 comments on commit 21d6cde

Please sign in to comment.