Blame src/blitter/ntapi_blt_free.c

dd89bb
/********************************************************/
dd89bb
/*  ntapi: Native API core library                      */
dd89bb
/*  Copyright (C) 2013,2014,2015  Z. Gilboa             */
dd89bb
/*  Released under GPLv2 and GPLv3; see COPYING.NTAPI.  */
dd89bb
/********************************************************/
dd89bb
dd89bb
#include <ntapi/nt_status.h>
dd89bb
#include <ntapi/nt_blitter.h>
dd89bb
#include <ntapi/nt_sync.h>
dd89bb
#include <ntapi/ntapi.h>
dd89bb
#include "ntapi_blitter.h"
dd89bb
#include "ntapi_impl.h"
dd89bb
dd89bb
int32_t __fastcall __ntapi_blt_free(nt_blitter * blt_ctx)
dd89bb
{
dd89bb
	int32_t	status;
dd89bb
	void *	region_addr;
dd89bb
	size_t	region_size;
dd89bb
dd89bb
	/* validation */
dd89bb
	if (!blt_ctx) return NT_STATUS_INVALID_PARAMETER;
dd89bb
dd89bb
	/* free blt block */
dd89bb
	region_addr = blt_ctx->info.region_addr;
dd89bb
	region_size = blt_ctx->info.region_size;
dd89bb
dd89bb
	if (region_size && !blt_ctx->params.region) {
dd89bb
		status = __ntapi->zw_free_virtual_memory(
dd89bb
			NT_CURRENT_PROCESS_HANDLE,
dd89bb
			&region_addr,
dd89bb
			&region_size,
dd89bb
			NT_MEM_RELEASE);
dd89bb
dd89bb
		if (status) return status;
dd89bb
	}
dd89bb
dd89bb
	/* free blt control block */
dd89bb
	region_addr = blt_ctx->addr;
dd89bb
	region_size = blt_ctx->size;
dd89bb
dd89bb
	status = __ntapi->zw_free_virtual_memory(
dd89bb
		NT_CURRENT_PROCESS_HANDLE,
dd89bb
		&region_addr,
dd89bb
		&region_size,
dd89bb
		NT_MEM_RELEASE);
dd89bb
dd89bb
	return status;
dd89bb
}