diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-10-09 12:57:22 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-10-09 12:57:22 +0200 |
commit | ce179bf6baed91ba84cc3ff647e96287c3b8e2f2 (patch) | |
tree | 47ccc59059e1b2565784bbaf8c9c778a39628cfa /Objects/bytesobject.c | |
parent | ad7715891e3c6c51b4860e0d496843ee5417206b (diff) | |
download | cpython-git-ce179bf6baed91ba84cc3ff647e96287c3b8e2f2.tar.gz |
Add _PyBytesWriter_WriteBytes() to factorize the code
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r-- | Objects/bytesobject.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 075edf8c67..3aa905c6fc 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -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; +} |