change API cs_close() to take pointer to handle as argument. this lets us invalidate the closed handle
diff --git a/cs.c b/cs.c
index d4afd4f..a96b435 100644
--- a/cs.c
+++ b/cs.c
@@ -177,12 +177,13 @@
 	}
 }
 
-cs_err cs_close(csh handle)
+cs_err cs_close(csh *handle)
 {
-	if (!handle)
+	if (*handle)
+		// invalid handle
 		return CS_ERR_CSH;
 
-	struct cs_struct *ud = (struct cs_struct *)(uintptr_t)handle;
+	struct cs_struct *ud = (struct cs_struct *)(*handle);
 
 	switch (ud->arch) {
 		case CS_ARCH_X86:
@@ -203,6 +204,9 @@
 	memset(ud, 0, sizeof(*ud));
 	cs_mem_free(ud);
 
+	// invalid this handle
+	*handle = 0;
+
 	return CS_ERR_OK;
 }