search for: pybytearray_size

Displaying 2 results from an estimated 2 matches for "pybytearray_size".

2019 Nov 23
1
[PATCH] python: Support buffer protocol for pread() result
...rray", + if (PyObject_GetBuffer (r, &view, PyBUF_SIMPLE) == -1) { + nbdkit_error ("%s: value returned from pread does not support the " + "buffer protocol", script); - Py_DECREF (r); - return -1; + goto out; } - if (PyByteArray_Size (r) < count) { - nbdkit_error ("%s: byte array returned from pread is too small", script); - Py_DECREF (r); - return -1; + if (view.len < count) { + nbdkit_error ("%s: buffer returned from pread is too small", script); + goto out; } - memcpy (buf, PyB...
2010 Sep 09
2
[PATCH]: add libxl python binding
...define CLS "ctx" + +static PyObject *xl_error_obj; + +static int fixed_bytearray_set(PyObject *v, uint8_t *ptr, size_t len) +{ + char *tmp; + size_t sz; + + if ( NULL == v ) { + memset(ptr, 0, len); + return 0; + } + if ( PyByteArray_Check(v) ) { + sz = PyByteArray_Size(v); + tmp = PyByteArray_AsString(v); + }else{ + Py_ssize_t ssz; + if ( PyString_AsStringAndSize(v, &tmp, &ssz) ) + return -1; + if ( ssz < 0 ) + tmp = NULL; + sz = ssz; + } + if ( NULL == tmp ) { + memset(ptr, 0, le...