Example #1
0
static void
tupledealloc(register PyTupleObject *op)
{
	JyNIDebugOp(JY_NATIVE_FINALIZE, op, -1);
	register Py_ssize_t i;
	register Py_ssize_t len =  Py_SIZE(op);
	_JyNI_GC_UNTRACK(op);
	Py_TRASHCAN_SAFE_BEGIN(op)
	if (len > 0) {
		i = len;
		while (--i >= 0)
			Py_XDECREF(op->ob_item[i]);
#if PyTuple_MAXSAVESIZE > 0
		if (len < PyTuple_MAXSAVESIZE &&
			numfree[len] < PyTuple_MAXFREELIST &&
			Py_TYPE(op) == &PyTuple_Type)
		{
			JyNIDebugOp(JY_NATIVE_FREE | JY_INLINE_MASK, op, -1);
			JyNI_CleanUp_JyObject(AS_JY_WITH_GC(op));
			op->ob_item[0] = (PyObject *) free_list[len];
			numfree[len]++;
			free_list[len] = op;
//			jputs("Release tuple to free_list");
//			jputsLong(len);
//			jputsLong((jlong) op);
			goto done; /* return */
		}
#endif
	}
	JyNI_CleanUp_JyObject(AS_JY_WITH_GC(op));
	Py_TYPE(op)->tp_free((PyObject *)op);
done:
	Py_TRASHCAN_SAFE_END(op)
}
Example #2
0
static void
frame_dealloc(PyFrameObject *f)
{
	JyObject* jy;
	JyNIDebugOp(JY_NATIVE_FINALIZE, f, -1);
	jy = AS_JY_NO_GC(f);
	JyNI_CleanUp_JyObject(jy);
	PyObject_RawFree(jy);
//	PyObject **p, **valuestack;
//	PyCodeObject *co;
//
//	PyObject_GC_UnTrack(f);
//	Py_TRASHCAN_SAFE_BEGIN(f)
//	/* Kill all local variables */
//	valuestack = f->f_valuestack;
//	for (p = f->f_localsplus; p < valuestack; p++)
//		Py_CLEAR(*p);
//
//	/* Free stack */
//	if (f->f_stacktop != NULL) {
//		for (p = valuestack; p < f->f_stacktop; p++)
//			Py_XDECREF(*p);
//	}
//
//	Py_XDECREF(f->f_back);
//	Py_DECREF(f->f_builtins);
//	Py_DECREF(f->f_globals);
//	Py_CLEAR(f->f_locals);
//	Py_CLEAR(f->f_trace);
//	Py_CLEAR(f->f_exc_type);
//	Py_CLEAR(f->f_exc_value);
//	Py_CLEAR(f->f_exc_traceback);
//
//	co = f->f_code;
//	if (co->co_zombieframe == NULL)
//		co->co_zombieframe = f;
//	else if (numfree < PyFrame_MAXFREELIST) {
//		++numfree;
//		f->f_back = free_list;
//		free_list = f;
//	}
//	else
//		PyObject_GC_Del(f);
//
//	Py_DECREF(co);
//	Py_TRASHCAN_SAFE_END(f)
}
Example #3
0
static void
slice_dealloc(PySliceObject *r)
{
	JyObject* jy = AS_JY_NO_GC(r);
	if (JyObject_IS_INITIALIZED(jy))
	{
		env();
		Py_DECREF(JyNI_PyObject_FromJythonPyObject((*env)->CallObjectMethod(env, jy->jy, pySliceGetStart)));
		Py_DECREF(JyNI_PyObject_FromJythonPyObject((*env)->CallObjectMethod(env, jy->jy, pySliceGetStop)));
		Py_DECREF(JyNI_PyObject_FromJythonPyObject((*env)->CallObjectMethod(env, jy->jy, pySliceGetStep)));
//		Py_DECREF(r->step);
//		Py_DECREF(r->start);
//		Py_DECREF(r->stop);
//		PyObject_Del(r);
	}
	JyNI_CleanUp_JyObject(jy);
	//PyObject_Del(jy);
	PyObject_RawFree(jy);
}