| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,12 +54,7 @@ Allocating Objects on the Heap | |||
| 54 | 54 | ||
| 55 | 55 | .. c:function:: void PyObject_Del(void *op) | |
| 56 | 56 | ||
| 57 | - Releases memory allocated to an object using :c:macro:`PyObject_New` or | ||
| 58 | - :c:macro:`PyObject_NewVar`. This is normally called from the | ||
| 59 | - :c:member:`~PyTypeObject.tp_dealloc` handler specified in the object's type. The fields of | ||
| 60 | - the object should not be accessed after this call as the memory is no | ||
| 61 | - longer a valid Python object. | ||
| 62 | - | ||
| 57 | + Same as :c:func:`PyObject_Free`. | ||
| 63 | 58 | ||
| 64 | 59 | .. c:var:: PyObject _Py_NoneStruct | |
| 65 | 60 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -734,7 +734,7 @@ The same code using the type-oriented function set:: | |||
| 734 | 734 | return PyErr_NoMemory(); | |
| 735 | 735 | /* ...Do some I/O operation involving buf... */ | |
| 736 | 736 | res = PyBytes_FromString(buf); | |
| 737 | - PyMem_Del(buf); /* allocated with PyMem_New */ | ||
| 737 | + PyMem_Free(buf); /* allocated with PyMem_New */ | ||
| 738 | 738 | return res; | |
| 739 | 739 | ||
| 740 | 740 | Note that in the two examples above, the buffer is always manipulated via | |
@@ -750,11 +750,11 @@ allocators operating on different heaps. :: | |||
| 750 | 750 | ... | |
| 751 | 751 | PyMem_Del(buf3); /* Wrong -- should be PyMem_Free() */ | |
| 752 | 752 | free(buf2); /* Right -- allocated via malloc() */ | |
| 753 | - free(buf1); /* Fatal -- should be PyMem_Del() */ | ||
| 753 | + free(buf1); /* Fatal -- should be PyMem_Free() */ | ||
| 754 | 754 | ||
| 755 | 755 | In addition to the functions aimed at handling raw memory blocks from the Python | |
| 756 | 756 | heap, objects in Python are allocated and released with :c:macro:`PyObject_New`, | |
| 757 | - :c:macro:`PyObject_NewVar` and :c:func:`PyObject_Del`. | ||
| 757 | + :c:macro:`PyObject_NewVar` and :c:func:`PyObject_Free`. | ||
| 758 | 758 | ||
| 759 | 759 | These will be explained in the next chapter on defining and implementing new | |
| 760 | 760 | object types in C. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -530,7 +530,7 @@ state_fini(SRE_STATE* state) | |||
| 530 | 530 | PyBuffer_Release(&state->buffer); | |
| 531 | 531 | Py_XDECREF(state->string); | |
| 532 | 532 | data_stack_dealloc(state); | |
| 533 | - /* See above PyMem_Del for why we explicitly cast here. */ | ||
| 533 | + /* See above PyMem_Free() for why we explicitly cast here. */ | ||
| 534 | 534 | PyMem_Free((void*) state->mark); | |
| 535 | 535 | state->mark = NULL; | |
| 536 | 536 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -269,16 +269,16 @@ test_type_from_ephemeral_spec(PyObject *self, PyObject *Py_UNUSED(ignored)) | |||
| 269 | 269 | // (Explicitly overwrite memory before freeing, | |
| 270 | 270 | // so bugs show themselves even without the debug allocator's help.) | |
| 271 | 271 | memset(spec, 0xdd, sizeof(PyType_Spec)); | |
| 272 | - PyMem_Del(spec); | ||
| 272 | + PyMem_Free(spec); | ||
| 273 | 273 | spec = NULL; | |
| 274 | 274 | memset(name, 0xdd, sizeof(NAME)); | |
| 275 | - PyMem_Del(name); | ||
| 275 | + PyMem_Free(name); | ||
| 276 | 276 | name = NULL; | |
| 277 | 277 | memset(doc, 0xdd, sizeof(DOC)); | |
| 278 | - PyMem_Del(doc); | ||
| 278 | + PyMem_Free(doc); | ||
| 279 | 279 | doc = NULL; | |
| 280 | 280 | memset(slots, 0xdd, 3 * sizeof(PyType_Slot)); | |
| 281 | - PyMem_Del(slots); | ||
| 281 | + PyMem_Free(slots); | ||
| 282 | 282 | slots = NULL; | |
| 283 | 283 | ||
| 284 | 284 | /* check that everything works */ | |
@@ -304,10 +304,10 @@ test_type_from_ephemeral_spec(PyObject *self, PyObject *Py_UNUSED(ignored)) | |||
| 304 | 304 | ||
| 305 | 305 | result = Py_NewRef(Py_None); | |
| 306 | 306 | finally: | |
| 307 | - PyMem_Del(spec); | ||
| 308 | - PyMem_Del(name); | ||
| 309 | - PyMem_Del(doc); | ||
| 310 | - PyMem_Del(slots); | ||
| 307 | + PyMem_Free(spec); | ||
| 308 | + PyMem_Free(name); | ||
| 309 | + PyMem_Free(doc); | ||
| 310 | + PyMem_Free(slots); | ||
| 311 | 311 | Py_XDECREF(class); | |
| 312 | 312 | Py_XDECREF(instance); | |
| 313 | 313 | Py_XDECREF(obj); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments