Remove \n
ACK
Add the upper limit, see comment I posted by mistake on the previous
patch.
ACK
Lets use one variable per line in new code.
ACK
K is unsigned long, we can use I (capital i) for int.
ACK
We need to validate lvb_len. If it is out of range (0 < lvb_len
<4096), we want to
raise a ValueError right here.
ACK
calloc(1, lv_len)
ACK
The nicest way would be to create a bytes object from lvb_data,
so it owns the data so we don't have to copy it twice. Python does
not support this, but we can do:
PyObject *result = NULL;
...
result = PyBytes_FromStringAndSize(NULL, lvb_len);
memset(PyBytes_AS_STRING(result), 0, lvb_len);
And pass the internal buffer to sanlock in the same way.
If the call fail we will clear the value, which decref the object and set
the pointer to NULL;
finally:
Py_XDECREF(lockspace);
Py_XDECREF(resource);
free(res);
if (rv < 0)
Py_CLEAR(result);
return result;
ACK