Skip to content

Commit db38b03

Browse files
committed
Doc: fix c-api sample code
1 parent 085d366 commit db38b03

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

‎Doc/c-api/bytes.rst‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ Variant using a pointer to compute the final size::
494494
495495
char *str = PyBytesWriter_GetData(writer);
496496
memcpy(str, "abc", 3);
497-
str += 1;
497+
str += 3;
498498
return PyBytesWriter_FinishWithPointer(writer, str);
499499
}
500500
@@ -543,7 +543,7 @@ Update ``_PyBytes_Resize()`` code
543543
544544
Example of code using the soft deprecated ``_PyBytes_Resize()`` API::
545545
546-
void create_string(Py_ssize_t size)
546+
PyObject* create_string(Py_ssize_t size)
547547
{
548548
PyObject *bytes = PyBytes_FromStringAndSize(NULL, size);
549549
if (bytes == NULL) {
@@ -561,7 +561,7 @@ Example of code using the soft deprecated ``_PyBytes_Resize()`` API::
561561
562562
It can now be updated to::
563563
564-
void create_string(Py_ssize_t size)
564+
PyObject* create_string(Py_ssize_t size)
565565
{
566566
PyBytesWriter *writer = PyBytesWriter_Create(size);
567567
if (writer == NULL) {

‎Doc/c-api/init_config.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ Example::
840840
if (PyStatus_Exception(status)) {
841841
Py_ExitStatusException(status);
842842
}
843-
PyMem_Free(ptr);
843+
PyMem_RawFree(ptr);
844844
return 0;
845845
}
846846

0 commit comments

Comments
 (0)