File: | _dynfuncmod.c |
Warning: | line 73, column 17 PyObject ownership leak with reference count of 1 |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | #include "_dynfunc.c" | |||
2 | ||||
3 | /* Python-facing function to dynamically create a new C function object */ | |||
4 | static PyObject* | |||
5 | make_function(PyObject *self, PyObject *args) | |||
6 | { | |||
7 | PyObject *module, *fname, *fdoc, *fnaddrobj; | |||
8 | void *fnaddr; | |||
9 | EnvironmentObject *env; | |||
10 | PyObject *keepalive; | |||
11 | ||||
12 | if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "OOOOO!|O", | |||
13 | &module, &fname, &fdoc, &fnaddrobj, &EnvironmentType, &env, | |||
14 | &keepalive)) { | |||
15 | return NULL((void*)0); | |||
16 | } | |||
17 | ||||
18 | fnaddr = PyLong_AsVoidPtr(fnaddrobj); | |||
19 | if (fnaddr == NULL((void*)0) && PyErr_Occurred()) | |||
20 | return NULL((void*)0); | |||
21 | ||||
22 | return pycfunction_new(module, fname, fdoc, fnaddr, env, keepalive); | |||
23 | } | |||
24 | ||||
25 | static PyMethodDef ext_methods[] = { | |||
26 | #define declmethod(func) { #func , ( PyCFunction )func , METH_VARARGS0x0001 , NULL((void*)0) } | |||
27 | declmethod(make_function), | |||
28 | { NULL((void*)0) }, | |||
29 | #undef declmethod | |||
30 | }; | |||
31 | ||||
32 | ||||
33 | static PyObject * | |||
34 | build_c_helpers_dict(void) | |||
35 | { | |||
36 | PyObject *dct = PyDict_New(); | |||
37 | if (dct == NULL((void*)0)) | |||
38 | goto error; | |||
39 | ||||
40 | #define _declpointer(name, value)do { PyObject *o = PyLong_FromVoidPtr(value); if (o == ((void *)0)) goto error; if (PyDict_SetItemString(dct, name, o)) { _Py_DECREF (((PyObject*)(o))); goto error; } _Py_DECREF(((PyObject*)(o)) ); } while (0) do { \ | |||
41 | PyObject *o = PyLong_FromVoidPtr(value); \ | |||
42 | if (o == NULL((void*)0)) goto error; \ | |||
43 | if (PyDict_SetItemString(dct, name, o)) { \ | |||
44 | Py_DECREF(o)_Py_DECREF(((PyObject*)(o))); \ | |||
45 | goto error; \ | |||
46 | } \ | |||
47 | Py_DECREF(o)_Py_DECREF(((PyObject*)(o))); \ | |||
48 | } while (0) | |||
49 | ||||
50 | #define declmethod(func) _declpointer(#func, &Numba_##func)do { PyObject *o = PyLong_FromVoidPtr(&Numba_##func); if ( o == ((void*)0)) goto error; if (PyDict_SetItemString(dct, #func , o)) { _Py_DECREF(((PyObject*)(o))); goto error; } _Py_DECREF (((PyObject*)(o))); } while (0) | |||
51 | ||||
52 | #define declpointer(ptr)do { PyObject *o = PyLong_FromVoidPtr(&ptr); if (o == ((void *)0)) goto error; if (PyDict_SetItemString(dct, "ptr", o)) { _Py_DECREF (((PyObject*)(o))); goto error; } _Py_DECREF(((PyObject*)(o)) ); } while (0) _declpointer(#ptr, &ptr)do { PyObject *o = PyLong_FromVoidPtr(&ptr); if (o == ((void *)0)) goto error; if (PyDict_SetItemString(dct, #ptr, o)) { _Py_DECREF (((PyObject*)(o))); goto error; } _Py_DECREF(((PyObject*)(o)) ); } while (0) | |||
53 | ||||
54 | declmethod(make_generator); | |||
55 | ||||
56 | #undef declmethod | |||
57 | return dct; | |||
58 | error: | |||
59 | Py_XDECREF(dct)_Py_XDECREF(((PyObject*)(dct))); | |||
60 | return NULL((void*)0); | |||
61 | } | |||
62 | ||||
63 | MOD_INIT(_dynfunc)PyObject* PyInit__dynfunc(void) { | |||
64 | PyObject *m, *impl_info; | |||
65 | ||||
66 | MOD_DEF(m, "_dynfunc", "No docs", ext_methods){ static struct PyModuleDef moduledef = { { { 1, ((void*)0) } , ((void*)0), 0, ((void*)0), }, "_dynfunc", "No docs", -1, ext_methods , ((void*)0), ((void*)0), ((void*)0), ((void*)0) }; m = PyModule_Create2 (&moduledef, 1013); } | |||
67 | if (m == NULL((void*)0)) | |||
| ||||
68 | return MOD_ERROR_VAL((void*)0); | |||
69 | ||||
70 | if (init_dynfunc_module(m)) | |||
71 | return MOD_ERROR_VAL((void*)0); | |||
72 | ||||
73 | impl_info = Py_BuildValue_Py_BuildValue_SizeT( | |||
| ||||
74 | "{snsnsn}", | |||
75 | "offsetof_closure_body", offsetof(ClosureObject, env)__builtin_offsetof(ClosureObject, env), | |||
76 | "offsetof_env_body", offsetof(EnvironmentObject, globals)__builtin_offsetof(EnvironmentObject, globals), | |||
77 | "offsetof_generator_state", offsetof(GeneratorObject, state)__builtin_offsetof(GeneratorObject, state) | |||
78 | ); | |||
79 | if (impl_info == NULL((void*)0)) | |||
80 | return MOD_ERROR_VAL((void*)0); | |||
81 | PyModule_AddObject(m, "_impl_info", impl_info); | |||
82 | ||||
83 | Py_INCREF(&ClosureType)_Py_INCREF(((PyObject*)(&ClosureType))); | |||
84 | PyModule_AddObject(m, "_Closure", (PyObject *) (&ClosureType)); | |||
85 | Py_INCREF(&EnvironmentType)_Py_INCREF(((PyObject*)(&EnvironmentType))); | |||
86 | PyModule_AddObject(m, "Environment", (PyObject *) (&EnvironmentType)); | |||
87 | Py_INCREF(&GeneratorType)_Py_INCREF(((PyObject*)(&GeneratorType))); | |||
88 | PyModule_AddObject(m, "_Generator", (PyObject *) (&GeneratorType)); | |||
89 | ||||
90 | PyModule_AddObject(m, "c_helpers", build_c_helpers_dict()); | |||
91 | ||||
92 | return MOD_SUCCESS_VAL(m)m; | |||
93 | } |
1 | #ifndef _Py_BuildValue_SizeT |
2 | PyObject* clang_analyzer_PyObject_New_Reference(); |
3 | PyObject* _Py_BuildValue_SizeT(const char *format, ...) { |
4 | return clang_analyzer_PyObject_New_Reference(); |
5 | } |
6 | #else |
7 | #warning "API _Py_BuildValue_SizeT is defined as a macro." |
8 | #endif |