Add _PyBytesWriter_WriteBytes() to factorize the code

This commit is contained in:
Victor Stinner 2015-10-09 12:57:22 +02:00
parent ad7715891e
commit ce179bf6ba
4 changed files with 35 additions and 16 deletions

View file

@ -3995,3 +3995,17 @@ _PyBytesWriter_Finish(_PyBytesWriter *writer, char *str)
return result;
}
char*
_PyBytesWriter_WriteBytes(_PyBytesWriter *writer, char *str,
char *bytes, Py_ssize_t size)
{
str = _PyBytesWriter_Prepare(writer, str, size);
if (str == NULL)
return NULL;
Py_MEMCPY(str, bytes, size);
str += size;
return str;
}