diff --git a/arch/AArch64/AArch64Module.c b/arch/AArch64/AArch64Module.c index 44965cf9d..35b08bdaa 100644 --- a/arch/AArch64/AArch64Module.c +++ b/arch/AArch64/AArch64Module.c @@ -38,8 +38,4 @@ cs_err AArch64_option(cs_struct *handle, cs_opt_type type, size_t value) return CS_ERR_OK; } -void AArch64_destroy(cs_struct *handle) -{ -} - #endif diff --git a/arch/AArch64/AArch64Module.h b/arch/AArch64/AArch64Module.h index e2b4a144a..73a132de8 100644 --- a/arch/AArch64/AArch64Module.h +++ b/arch/AArch64/AArch64Module.h @@ -8,6 +8,5 @@ cs_err AArch64_global_init(cs_struct *ud); cs_err AArch64_option(cs_struct *handle, cs_opt_type type, size_t value); -void AArch64_destroy(cs_struct *handle); #endif diff --git a/arch/ARM/ARMModule.c b/arch/ARM/ARMModule.c index 3287fa9c9..642ce3724 100644 --- a/arch/ARM/ARMModule.c +++ b/arch/ARM/ARMModule.c @@ -57,8 +57,4 @@ cs_err ARM_option(cs_struct *handle, cs_opt_type type, size_t value) return CS_ERR_OK; } -void ARM_destroy(cs_struct *handle) -{ -} - #endif diff --git a/arch/ARM/ARMModule.h b/arch/ARM/ARMModule.h index 57619610a..f84497212 100644 --- a/arch/ARM/ARMModule.h +++ b/arch/ARM/ARMModule.h @@ -8,6 +8,5 @@ cs_err ARM_global_init(cs_struct *ud); cs_err ARM_option(cs_struct *handle, cs_opt_type type, size_t value); -void ARM_destroy(cs_struct *handle); #endif diff --git a/arch/Mips/MipsModule.c b/arch/Mips/MipsModule.c index 07740da16..44351f590 100644 --- a/arch/Mips/MipsModule.c +++ b/arch/Mips/MipsModule.c @@ -57,8 +57,4 @@ cs_err Mips_option(cs_struct *handle, cs_opt_type type, size_t value) return CS_ERR_OK; } -void Mips_destroy(cs_struct *handle) -{ -} - #endif diff --git a/arch/Mips/MipsModule.h b/arch/Mips/MipsModule.h index ffc5648b5..d1aa2cfff 100644 --- a/arch/Mips/MipsModule.h +++ b/arch/Mips/MipsModule.h @@ -8,6 +8,5 @@ cs_err Mips_global_init(cs_struct *ud); cs_err Mips_option(cs_struct *handle, cs_opt_type type, size_t value); -void Mips_destroy(cs_struct *handle); #endif diff --git a/arch/PowerPC/PPCModule.c b/arch/PowerPC/PPCModule.c index 7a29da00b..58956cc37 100644 --- a/arch/PowerPC/PPCModule.c +++ b/arch/PowerPC/PPCModule.c @@ -42,8 +42,4 @@ cs_err PPC_option(cs_struct *handle, cs_opt_type type, size_t value) return CS_ERR_OK; } -void PPC_destroy(cs_struct *handle) -{ -} - #endif diff --git a/arch/PowerPC/PPCModule.h b/arch/PowerPC/PPCModule.h index 2de0ea574..079cf600f 100644 --- a/arch/PowerPC/PPCModule.h +++ b/arch/PowerPC/PPCModule.h @@ -8,6 +8,5 @@ cs_err PPC_global_init(cs_struct *ud); cs_err PPC_option(cs_struct *handle, cs_opt_type type, size_t value); -void PPC_destroy(cs_struct *handle); #endif diff --git a/arch/Sparc/SparcModule.c b/arch/Sparc/SparcModule.c index 566354e80..2e42f7931 100644 --- a/arch/Sparc/SparcModule.c +++ b/arch/Sparc/SparcModule.c @@ -42,8 +42,4 @@ cs_err Sparc_option(cs_struct *handle, cs_opt_type type, size_t value) return CS_ERR_OK; } -void Sparc_destroy(cs_struct *handle) -{ -} - #endif diff --git a/arch/Sparc/SparcModule.h b/arch/Sparc/SparcModule.h index a383f2860..1caaac1a4 100644 --- a/arch/Sparc/SparcModule.h +++ b/arch/Sparc/SparcModule.h @@ -8,6 +8,5 @@ cs_err Sparc_global_init(cs_struct *ud); cs_err Sparc_option(cs_struct *handle, cs_opt_type type, size_t value); -void Sparc_destroy(cs_struct *handle); #endif diff --git a/arch/SystemZ/SystemZModule.c b/arch/SystemZ/SystemZModule.c index d3cf71c02..2d83da05c 100644 --- a/arch/SystemZ/SystemZModule.c +++ b/arch/SystemZ/SystemZModule.c @@ -41,8 +41,4 @@ cs_err SystemZ_option(cs_struct *handle, cs_opt_type type, size_t value) return CS_ERR_OK; } -void SystemZ_destroy(cs_struct *handle) -{ -} - #endif diff --git a/arch/SystemZ/SystemZModule.h b/arch/SystemZ/SystemZModule.h index f605d9623..ad403baf5 100644 --- a/arch/SystemZ/SystemZModule.h +++ b/arch/SystemZ/SystemZModule.h @@ -8,6 +8,5 @@ cs_err SystemZ_global_init(cs_struct *ud); cs_err SystemZ_option(cs_struct *handle, cs_opt_type type, size_t value); -void SystemZ_destroy(cs_struct *handle); #endif diff --git a/arch/X86/X86Module.c b/arch/X86/X86Module.c index 8c51b9126..ef0357c71 100644 --- a/arch/X86/X86Module.c +++ b/arch/X86/X86Module.c @@ -83,8 +83,4 @@ cs_err X86_option(cs_struct *handle, cs_opt_type type, size_t value) return CS_ERR_OK; } -void X86_destroy(cs_struct *handle) -{ -} - #endif diff --git a/arch/X86/X86Module.h b/arch/X86/X86Module.h index 464ad9cfb..53d13eded 100644 --- a/arch/X86/X86Module.h +++ b/arch/X86/X86Module.h @@ -8,6 +8,5 @@ cs_err X86_global_init(cs_struct *ud); cs_err X86_option(cs_struct *handle, cs_opt_type type, size_t value); -void X86_destroy(cs_struct *handle); #endif diff --git a/arch/XCore/XCoreModule.c b/arch/XCore/XCoreModule.c index e475d7558..6b4aa66ff 100644 --- a/arch/XCore/XCoreModule.c +++ b/arch/XCore/XCoreModule.c @@ -38,8 +38,4 @@ cs_err XCore_option(cs_struct *handle, cs_opt_type type, size_t value) return CS_ERR_OK; } -void XCore_destroy(cs_struct *handle) -{ -} - #endif diff --git a/arch/XCore/XCoreModule.h b/arch/XCore/XCoreModule.h index 3f2d608bb..c4a7d2b26 100644 --- a/arch/XCore/XCoreModule.h +++ b/arch/XCore/XCoreModule.h @@ -8,6 +8,5 @@ cs_err XCore_global_init(cs_struct *ud); cs_err XCore_option(cs_struct *handle, cs_opt_type type, size_t value); -void XCore_destroy(cs_struct *handle); #endif diff --git a/cs.c b/cs.c index f69cb4237..f0a64971d 100644 --- a/cs.c +++ b/cs.c @@ -62,7 +62,8 @@ #include "arch/XCore/XCoreModule.h" -cs_err (*cs_arch_init[MAX_ARCH])(cs_struct *) = { +// constructor initialization for all archs +static cs_err (*cs_arch_init[MAX_ARCH])(cs_struct *) = { #ifdef CAPSTONE_HAS_ARM ARM_global_init, #else @@ -105,7 +106,8 @@ cs_err (*cs_arch_init[MAX_ARCH])(cs_struct *) = { #endif }; -cs_err (*cs_arch_option[MAX_ARCH]) (cs_struct *, cs_opt_type, size_t value) = { +// support cs_option() for all archs +static cs_err (*cs_arch_option[MAX_ARCH]) (cs_struct *, cs_opt_type, size_t value) = { #ifdef CAPSTONE_HAS_ARM ARM_option, #else @@ -148,49 +150,8 @@ cs_err (*cs_arch_option[MAX_ARCH]) (cs_struct *, cs_opt_type, size_t value) = { #endif }; -void (*cs_arch_destroy[MAX_ARCH]) (cs_struct *) = { -#ifdef CAPSTONE_HAS_ARM - ARM_destroy, -#else - NULL, -#endif -#ifdef CAPSTONE_HAS_ARM64 - AArch64_destroy, -#else - NULL, -#endif -#ifdef CAPSTONE_HAS_MIPS - Mips_destroy, -#else - NULL, -#endif -#ifdef CAPSTONE_HAS_X86 - X86_destroy, -#else - NULL, -#endif -#ifdef CAPSTONE_HAS_POWERPC - PPC_destroy, -#else - NULL, -#endif -#ifdef CAPSTONE_HAS_SPARC - Sparc_destroy, -#else - NULL, -#endif -#ifdef CAPSTONE_HAS_SYSZ - SystemZ_destroy, -#else - NULL, -#endif -#ifdef CAPSTONE_HAS_XCORE - XCore_destroy, -#else - NULL, -#endif -}; - +// bitmask for finding disallowed modes for an arch: +// to be called in cs_open()/cs_option() cs_mode cs_arch_disallowed_mode_mask[MAX_ARCH] = { #ifdef CAPSTONE_HAS_ARM ~(CS_MODE_LITTLE_ENDIAN | CS_MODE_ARM | CS_MODE_V8 | CS_MODE_MCLASS | CS_MODE_THUMB | CS_MODE_BIG_ENDIAN), @@ -235,7 +196,7 @@ cs_mode cs_arch_disallowed_mode_mask[MAX_ARCH] = { #endif }; -unsigned int all_arch = +static unsigned int all_arch = #ifdef CAPSTONE_HAS_ARM (1 << CS_ARCH_ARM) #else diff --git a/cs_priv.h b/cs_priv.h index 4bbccd039..556a9c958 100644 --- a/cs_priv.h +++ b/cs_priv.h @@ -60,21 +60,6 @@ struct cs_struct { // Returns a bool (0 or 1) whether big endian is enabled for a mode #define MODE_IS_BIG_ENDIAN(mode) (((mode) & CS_MODE_BIG_ENDIAN) != 0) -// constructor initialization for all archs -extern cs_err (*cs_arch_init[MAX_ARCH]) (cs_struct *); - -// support cs_option() for all archs -extern cs_err (*cs_arch_option[MAX_ARCH]) (cs_struct*, cs_opt_type, size_t value); - -// deinitialized functions: to be called when cs_close() is called -extern void (*cs_arch_destroy[MAX_ARCH]) (cs_struct*); - -// bitmask for finding disallowed modes for an arch: -// to be called in cs_open()/cs_option() -extern cs_mode cs_arch_disallowed_mode_mask[MAX_ARCH]; - -extern unsigned int all_arch; - extern cs_malloc_t cs_mem_malloc; extern cs_calloc_t cs_mem_calloc; extern cs_realloc_t cs_mem_realloc;