Skip to content

Instantly share code, notes, and snippets.

@filipevarjao
Last active September 28, 2017 19:44
Show Gist options
  • Save filipevarjao/470d2ee0665fbc3671ad8897187ef441 to your computer and use it in GitHub Desktop.
Save filipevarjao/470d2ee0665fbc3671ad8897187ef441 to your computer and use it in GitHub Desktop.
typedef struct _object {
_PyObject_HEAD_EXTRA
Py_ssize_t ob_refcnt;
int color; /* the color of local mark-scan where 0 black, 1 red 2 green */
struct _typeobject *ob_type;
} PyObject;
#define _Py_CHECK_REFCNT(OP) \
{ if (((PyObject*)OP)->ob_refcnt < 0) \
_Py_NegativeRefcount(__FILE__, __LINE__, \
(PyObject *)(OP)); \
else
}
@acmh
Copy link

acmh commented Sep 28, 2017

You can assign the color just writing:

((PyObject*)OP)->color = 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment