Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d7777b9

Browse files
committed
Define and document Py_IncRef/Py_DecRef
1 parent de3874c commit d7777b9

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/runtime/runtime.cs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,6 @@ internal static Type[] PythonArgsToTypeArray(IntPtr arg, bool mangleObjects)
500500
internal static unsafe void XIncref(IntPtr op)
501501
{
502502
#if PYTHON_WITH_PYDEBUG
503-
// according to Python doc, Py_IncRef() is Py_XINCREF()
504503
Py_IncRef(op);
505504
return;
506505
#else
@@ -522,8 +521,6 @@ internal static unsafe void XIncref(IntPtr op)
522521
internal static unsafe void XDecref(IntPtr op)
523522
{
524523
#if PYTHON_WITH_PYDEBUG
525-
// Py_DecRef calls Python's Py_DECREF
526-
// according to Python doc, Py_DecRef() is Py_XDECREF()
527524
Py_DecRef(op);
528525
return;
529526
#else
@@ -568,15 +565,21 @@ internal static unsafe long Refcount(IntPtr op)
568565
return Is32Bit ? (*(int*)p) : (*(long*)p);
569566
}
570567

571-
#if PYTHON_WITH_PYDEBUG
572-
// Py_IncRef and Py_DecRef are taking care of the extra payload
573-
// in Py_DEBUG builds of Python like _Py_RefTotal
568+
/// <summary>
569+
/// Export of Macro Py_XIncRef. Use XIncref instead.
570+
/// Limit this function usage for Testing and Py_Debug builds
571+
/// </summary>
572+
/// <param name="ob">PyObject Ptr</param>
574573
[DllImport(PythonDll)]
575-
private static extern void Py_IncRef(IntPtr ob);
574+
internal static extern void Py_IncRef(IntPtr ob);
576575

576+
/// <summary>
577+
/// Export of Macro Py_XDecRef. Use XDecref instead.
578+
/// Limit this function usage for Testing and Py_Debug builds
579+
/// </summary>
580+
/// <param name="ob">PyObject Ptr</param>
577581
[DllImport(PythonDll)]
578-
private static extern void Py_DecRef(IntPtr ob);
579-
#endif
582+
internal static extern void Py_DecRef(IntPtr ob);
580583

581584
[DllImport(PythonDll)]
582585
internal static extern void Py_Initialize();

0 commit comments

Comments
 (0)