File tree Expand file tree Collapse file tree 1 file changed +39
-1
lines changed
Expand file tree Collapse file tree 1 file changed +39
-1
lines changed Original file line number Diff line number Diff line change 88#include "pycore_object.h" // _PyObject_GC_TRACK()
99#include "recordobject.h"
1010
11+ static inline void
12+ record_gc_track (PyRecordObject * op )
13+ {
14+ _PyObject_GC_TRACK (op );
15+ }
16+
17+ static PyRecordObject *
18+ record_alloc (Py_ssize_t size )
19+ {
20+ PyRecordObject * op ;
21+ if (size < 0 ) {
22+ PyErr_BadInternalCall ();
23+ return NULL ;
24+ }
25+
26+ {
27+ /* Check for overflow */
28+ if ((size_t )size > ((size_t )PY_SSIZE_T_MAX - (sizeof (PyRecordObject ) -
29+ sizeof (PyObject * ))) / sizeof (PyObject * )) {
30+ return (PyRecordObject * )PyErr_NoMemory ();
31+ }
32+ op = PyObject_GC_NewVar (PyRecordObject , & PyRecord_Type , size );
33+ if (op == NULL )
34+ return NULL ;
35+ }
36+ return op ;
37+ }
38+
1139PyAPI_FUNC (PyObject * ) PyRecord_New (Py_ssize_t size )
1240{
13- return NULL ;
41+ PyRecordObject * op ;
42+ op = record_alloc (size );
43+ if (op == NULL ) {
44+ return NULL ;
45+ }
46+ op -> names = NULL ;
47+ for (Py_ssize_t i = 0 ; i < size ; i ++ ) {
48+ op -> ob_item [i ] = NULL ;
49+ }
50+ record_gc_track (op );
51+ return (PyObject * ) op ;
1452}
1553
1654static void
You can’t perform that action at this time.
0 commit comments