-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchanges.diff
More file actions
42 lines (39 loc) · 1.14 KB
/
changes.diff
File metadata and controls
42 lines (39 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
--- custom_orig.c 2018-11-04 11:20:30.076989050 +0000
+++ custom.c 2018-11-04 11:21:59.550788794 +0000
@@ -5,14 +5,19 @@
PyObject_HEAD
PyObject *first; /* first name */
PyObject *last; /* last name */
+ PyObject *test_field; /* last name */
int number;
} CustomObject;
+static PyTypeObject CustomType;
+
static void
Custom_dealloc(CustomObject *self)
{
Py_XDECREF(self->first);
Py_XDECREF(self->last);
+ puts("deallocating weird pointer");
+ Py_XDECREF(self->test_field);
Py_TYPE(self)->tp_free((PyObject *) self);
}
@@ -20,7 +25,9 @@
Custom_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
CustomObject *self;
- self = (CustomObject *) type->tp_alloc(type, 0);
+ //self = (CustomObject *) type->tp_alloc(type, 0);
+ self = PyObject_New(CustomObject, &CustomType);
+ printf("weird pointer has value of: 0x%x\n", self->test_field);
if (self != NULL) {
self->first = PyUnicode_FromString("");
if (self->first == NULL) {
@@ -116,7 +123,7 @@
};
PyMODINIT_FUNC
-PyInit_custom2(void)
+PyInit_custom(void)
{
PyObject *m;
if (PyType_Ready(&CustomType) < 0)