示例#1
0
/* Tests the libevt_record_free function
 * Returns 1 if successful or 0 if not
 */
int evt_test_record_free(
     void )
{
	libcerror_error_t *error = NULL;
	int result               = 0;

	/* Test error cases
	 */
	result = libevt_record_free(
	          NULL,
	          &error );

	EVT_TEST_ASSERT_EQUAL_INT(
	 "result",
	 result,
	 -1 );

	EVT_TEST_ASSERT_IS_NOT_NULL(
	 "error",
	 error );

	libcerror_error_free(
	 &error );

	return( 1 );

on_error:
	if( error != NULL )
	{
		libcerror_error_free(
		 &error );
	}
	return( 0 );
}
示例#2
0
/* Frees a record object
 */
void pyevt_record_free(
      pyevt_record_t *pyevt_record )
{
	libcerror_error_t *error = NULL;
	static char *function    = "pyevt_record_free";
	int result               = 0;

	if( pyevt_record == NULL )
	{
		PyErr_Format(
		 PyExc_TypeError,
		 "%s: invalid record.",
		 function );

		return;
	}
	if( pyevt_record->ob_type == NULL )
	{
		PyErr_Format(
		 PyExc_TypeError,
		 "%s: invalid record - missing ob_type.",
		 function );

		return;
	}
	if( pyevt_record->ob_type->tp_free == NULL )
	{
		PyErr_Format(
		 PyExc_TypeError,
		 "%s: invalid record - invalid ob_type - missing tp_free.",
		 function );

		return;
	}
	if( pyevt_record->record == NULL )
	{
		PyErr_Format(
		 PyExc_TypeError,
		 "%s: invalid record - missing libevt record.",
		 function );

		return;
	}
	Py_BEGIN_ALLOW_THREADS

	result = libevt_record_free(
	          &( pyevt_record->record ),
	          &error );

	Py_END_ALLOW_THREADS

	if( result != 1 )
	{
		pyevt_error_raise(
		 error,
		 PyExc_IOError,
		 "%s: unable to free libevt record.",
		 function );

		libcerror_error_free(
		 &error );
	}
	if( pyevt_record->file_object != NULL )
	{
		Py_DecRef(
		 (PyObject *) pyevt_record->file_object );
	}
	pyevt_record->ob_type->tp_free(
	 (PyObject*) pyevt_record );
}