summaryrefslogtreecommitdiffhomepage
path: root/src/blitter/ntapi_blt_free.c
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2015-07-27 04:01:18 -0400
committermidipix <writeonce@midipix.org>2015-07-27 04:01:18 -0400
commitdd89bb8ad4fe184a34b5dbdda237e640fc82121b (patch)
tree5e80d2da35f5892f92be29f57982b2708e6bd99b /src/blitter/ntapi_blt_free.c
parentdcdadc2702712fa750ed255ed1dfa354522797a0 (diff)
downloadntapi-dd89bb8ad4fe184a34b5dbdda237e640fc82121b.tar.bz2
ntapi-dd89bb8ad4fe184a34b5dbdda237e640fc82121b.tar.xz
entered advanced internal development stage.
Diffstat (limited to 'src/blitter/ntapi_blt_free.c')
-rw-r--r--src/blitter/ntapi_blt_free.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/blitter/ntapi_blt_free.c b/src/blitter/ntapi_blt_free.c
new file mode 100644
index 0000000..a5956b1
--- /dev/null
+++ b/src/blitter/ntapi_blt_free.c
@@ -0,0 +1,48 @@
+/********************************************************/
+/* ntapi: Native API core library */
+/* Copyright (C) 2013,2014,2015 Z. Gilboa */
+/* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */
+/********************************************************/
+
+#include <ntapi/nt_status.h>
+#include <ntapi/nt_blitter.h>
+#include <ntapi/nt_sync.h>
+#include <ntapi/ntapi.h>
+#include "ntapi_blitter.h"
+#include "ntapi_impl.h"
+
+int32_t __fastcall __ntapi_blt_free(nt_blitter * blt_ctx)
+{
+ int32_t status;
+ void * region_addr;
+ size_t region_size;
+
+ /* validation */
+ if (!blt_ctx) return NT_STATUS_INVALID_PARAMETER;
+
+ /* free blt block */
+ region_addr = blt_ctx->info.region_addr;
+ region_size = blt_ctx->info.region_size;
+
+ if (region_size && !blt_ctx->params.region) {
+ status = __ntapi->zw_free_virtual_memory(
+ NT_CURRENT_PROCESS_HANDLE,
+ &region_addr,
+ &region_size,
+ NT_MEM_RELEASE);
+
+ if (status) return status;
+ }
+
+ /* free blt control block */
+ region_addr = blt_ctx->addr;
+ region_size = blt_ctx->size;
+
+ status = __ntapi->zw_free_virtual_memory(
+ NT_CURRENT_PROCESS_HANDLE,
+ &region_addr,
+ &region_size,
+ NT_MEM_RELEASE);
+
+ return status;
+}