this repo has no description
at trunk 48 lines 1.6 kB view raw
1// Copyright (c) Facebook, Inc. and its affiliates. (http://www.facebook.com) 2#include "cpython-data.h" 3#include "cpython-func.h" 4 5#include "api-handle.h" 6#include "runtime.h" 7 8namespace py { 9 10PY_EXPORT Py_ssize_t PyGC_Collect() { UNIMPLEMENTED("PyGC_Collect"); } 11 12// Releases memory allocated to an object using PyObject_GC_New() or 13// PyObject_GC_NewVar(). 14PY_EXPORT void PyObject_GC_Del(void* op) { PyObject_Free(op); } 15 16PY_EXPORT void PyObject_GC_Track(void*) {} 17 18PY_EXPORT void PyObject_GC_UnTrack(void*) {} 19 20PY_EXPORT PyObject* _PyObject_GC_Malloc(size_t basicsize) { 21 return reinterpret_cast<PyObject*>(PyObject_Malloc(basicsize)); 22} 23 24PY_EXPORT PyObject* _PyObject_GC_Calloc(size_t basicsize) { 25 return reinterpret_cast<PyObject*>(PyObject_Calloc(1, basicsize)); 26} 27 28PY_EXPORT PyObject* _PyObject_GC_New(PyTypeObject* type) { 29 PyObject* obj = 30 static_cast<PyObject*>(_PyObject_GC_Malloc(_PyObject_SIZE(type))); 31 if (obj == nullptr) return PyErr_NoMemory(); 32 return PyObject_INIT(obj, type); 33} 34 35PY_EXPORT PyVarObject* _PyObject_GC_NewVar(PyTypeObject* type, 36 Py_ssize_t nitems) { 37 PyObject* obj = static_cast<PyObject*>( 38 _PyObject_GC_Malloc(_PyObject_VAR_SIZE(type, nitems))); 39 if (obj == nullptr) return reinterpret_cast<PyVarObject*>(PyErr_NoMemory()); 40 return PyObject_INIT_VAR(obj, type, nitems); 41} 42 43PY_EXPORT PyVarObject* _PyObject_GC_Resize(PyVarObject* /* p */, 44 Py_ssize_t /* s */) { 45 UNIMPLEMENTED("_PyObject_GC_Resize"); 46} 47 48} // namespace py