char type_instance[DATA_MAX_NAME_LEN];
} PluginData;
PyTypeObject PluginDataType;
+#define PluginData_New() PyObject_CallFunctionObjArgs((PyObject *) &PluginDataType, (void *) 0)
typedef struct {
PluginData data;
int interval;
} Values;
PyTypeObject ValuesType;
+#define Values_New() PyObject_CallFunctionObjArgs((PyObject *) &ValuesType, (void *) 0)
typedef struct {
PluginData data;
char message[NOTIF_MAX_MSG_LEN];
} Notification;
PyTypeObject NotificationType;
+#define Notification_New() PyObject_CallFunctionObjArgs((PyObject *) &NotificationType, (void *) 0)
typedef PyLongObject Signed;
PyTypeObject SignedType;
typedef PyLongObject Unsigned;
PyTypeObject UnsignedType;
+
static int cpy_write_callback(const data_set_t *ds, const value_list_t *value_list, user_data_t *data) {
int i;
cpy_callback_t *c = data->data;
- PyObject *ret, *list, *temp, *dict = NULL;
+ PyObject *ret, *list, *temp, *dict = NULL, *val;
Values *v;
CPY_LOCK_THREADS
}
free(table);
}
- v = PyObject_New(Values, (void *) &ValuesType); /* New reference. */
+ val = Values_New(); /* New reference. */
+ v = (Values *) val;
sstrncpy(v->data.host, value_list->host, sizeof(v->data.host));
sstrncpy(v->data.type, value_list->type, sizeof(v->data.type));
sstrncpy(v->data.type_instance, value_list->type_instance, sizeof(v->data.type_instance));
sstrncpy(v->data.plugin_instance, value_list->plugin_instance, sizeof(v->data.plugin_instance));
v->data.time = value_list->time;
v->interval = value_list->interval;
+ Py_CLEAR(v->values);
v->values = list;
+ Py_CLEAR(v->meta);
v->meta = dict;
ret = PyObject_CallFunctionObjArgs(c->callback, v, c->data, (void *) 0); /* New reference. */
- Py_XDECREF(v);
+ Py_XDECREF(val);
if (ret == NULL) {
cpy_log_exception("write callback");
} else {
static int cpy_notification_callback(const notification_t *notification, user_data_t *data) {
cpy_callback_t *c = data->data;
- PyObject *ret;
+ PyObject *ret, *notify;
Notification *n;
CPY_LOCK_THREADS
- n = PyObject_New(Notification, (void *) &NotificationType); /* New reference. */
+ notify = Notification_New(); /* New reference. */
+ n = (Notification *) notify;
sstrncpy(n->data.host, notification->host, sizeof(n->data.host));
sstrncpy(n->data.type, notification->type, sizeof(n->data.type));
sstrncpy(n->data.type_instance, notification->type_instance, sizeof(n->data.type_instance));
sstrncpy(n->message, notification->message, sizeof(n->message));
n->severity = notification->severity;
ret = PyObject_CallFunctionObjArgs(c->callback, n, c->data, (void *) 0); /* New reference. */
- Py_XDECREF(n);
+ Py_XDECREF(notify);
if (ret == NULL) {
cpy_log_exception("notification callback");
} else {