mirror of
https://github.com/python/cpython.git
synced 2025-08-02 08:02:56 +00:00
Relax _PyBytesWriter API
Don't require _PyBytesWriter pointer to be a "char *". Same change for _PyBytesWriter_WriteBytes() parameter. For example, binascii uses "unsigned char*".
This commit is contained in:
parent
b031eaee3b
commit
c29e29bed1
2 changed files with 14 additions and 15 deletions
|
@ -3923,8 +3923,8 @@ _PyBytesWriter_CheckConsistency(_PyBytesWriter *writer, char *str)
|
|||
#endif
|
||||
}
|
||||
|
||||
char*
|
||||
_PyBytesWriter_Prepare(_PyBytesWriter *writer, char *str, Py_ssize_t size)
|
||||
void*
|
||||
_PyBytesWriter_Prepare(_PyBytesWriter *writer, void *str, Py_ssize_t size)
|
||||
{
|
||||
Py_ssize_t allocated, pos;
|
||||
|
||||
|
@ -3992,7 +3992,7 @@ _PyBytesWriter_Prepare(_PyBytesWriter *writer, char *str, Py_ssize_t size)
|
|||
/* Allocate the buffer to write size bytes.
|
||||
Return the pointer to the beginning of buffer data.
|
||||
Raise an exception and return NULL on error. */
|
||||
char*
|
||||
void*
|
||||
_PyBytesWriter_Alloc(_PyBytesWriter *writer, Py_ssize_t size)
|
||||
{
|
||||
/* ensure that _PyBytesWriter_Alloc() is only called once */
|
||||
|
@ -4011,7 +4011,7 @@ _PyBytesWriter_Alloc(_PyBytesWriter *writer, Py_ssize_t size)
|
|||
}
|
||||
|
||||
PyObject *
|
||||
_PyBytesWriter_Finish(_PyBytesWriter *writer, char *str)
|
||||
_PyBytesWriter_Finish(_PyBytesWriter *writer, void *str)
|
||||
{
|
||||
Py_ssize_t pos;
|
||||
PyObject *result;
|
||||
|
@ -4033,13 +4033,12 @@ _PyBytesWriter_Finish(_PyBytesWriter *writer, char *str)
|
|||
else {
|
||||
result = PyBytes_FromStringAndSize(writer->small_buffer, pos);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
char*
|
||||
_PyBytesWriter_WriteBytes(_PyBytesWriter *writer, char *str,
|
||||
char *bytes, Py_ssize_t size)
|
||||
void*
|
||||
_PyBytesWriter_WriteBytes(_PyBytesWriter *writer, void *str,
|
||||
const void *bytes, Py_ssize_t size)
|
||||
{
|
||||
str = _PyBytesWriter_Prepare(writer, str, size);
|
||||
if (str == NULL)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue