From 6bf49d49e75c58fbec5c2f33d818f762bb0ca467 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Tue, 26 Mar 2013 18:15:58 +0400 Subject: [PATCH] Drop CvModule and cvSetMemoryManager --- modules/core/include/opencv2/core/core_c.h | 34 +---- modules/core/src/alloc.cpp | 5 - modules/core/src/system.cpp | 119 ------------------ .../legacy/include/opencv2/legacy/compat.hpp | 5 +- 4 files changed, 8 insertions(+), 155 deletions(-) diff --git a/modules/core/include/opencv2/core/core_c.h b/modules/core/include/opencv2/core/core_c.h index 4c4b390467..f44f99d92f 100644 --- a/modules/core/include/opencv2/core/core_c.h +++ b/modules/core/include/opencv2/core/core_c.h @@ -1478,27 +1478,9 @@ CVAPI(int) cvKMeans2( const CvArr* samples, int cluster_count, CvArr* labels, * System functions * \****************************************************************************************/ -/* Add the function pointers table with associated information to the IPP primitives list */ -CVAPI(int) cvRegisterModule( const CvModuleInfo* module_info ); - /* Loads optimized functions from IPP, MKL etc. or switches back to pure C code */ CVAPI(int) cvUseOptimized( int on_off ); -/* Retrieves information about the registered modules and loaded optimized plugins */ -CVAPI(void) cvGetModuleInfo( const char* module_name, - const char** version, - const char** loaded_addon_plugins ); - -typedef void* (CV_CDECL *CvAllocFunc)(size_t size, void* userdata); -typedef int (CV_CDECL *CvFreeFunc)(void* pptr, void* userdata); - -/* Set user-defined memory managment functions (substitutors for malloc and free) that - will be called by cvAlloc, cvFree and higher-level functions (e.g. cvCreateImage) */ -CVAPI(void) cvSetMemoryManager( CvAllocFunc alloc_func CV_DEFAULT(NULL), - CvFreeFunc free_func CV_DEFAULT(NULL), - void* userdata CV_DEFAULT(NULL)); - - typedef IplImage* (CV_STDCALL* Cv_iplCreateImageHeader) (int,int,int,char*,char*,int,int,int,int,int, IplROI*,IplImage*,void*,IplTileInfo*); @@ -1843,19 +1825,11 @@ static char cvFuncName[] = Name #define __CV_EXIT__ goto exit #ifdef __cplusplus -} - -// classes for automatic module/RTTI data registration/unregistration -struct CV_EXPORTS CvModule -{ - CvModule( CvModuleInfo* _info ); - ~CvModule(); - CvModuleInfo* info; - - static CvModuleInfo* first; - static CvModuleInfo* last; -}; +} // extern "C" +#endif +#ifdef __cplusplus +// class for automatic module/RTTI data registration/unregistration struct CV_EXPORTS CvType { CvType( const char* type_name, diff --git a/modules/core/src/alloc.cpp b/modules/core/src/alloc.cpp index 1944ed17de..c830df23c5 100644 --- a/modules/core/src/alloc.cpp +++ b/modules/core/src/alloc.cpp @@ -683,11 +683,6 @@ void fastFree( void* ptr ) } -CV_IMPL void cvSetMemoryManager( CvAllocFunc, CvFreeFunc, void * ) -{ - CV_Error( -1, "Custom memory allocator is not supported" ); -} - CV_IMPL void* cvAlloc( size_t size ) { return cv::fastMalloc( size ); diff --git a/modules/core/src/system.cpp b/modules/core/src/system.cpp index c06e87b285..8dae1efd31 100644 --- a/modules/core/src/system.cpp +++ b/modules/core/src/system.cpp @@ -671,125 +671,6 @@ cvErrorFromIppStatus( int status ) } } -static CvModuleInfo cxcore_info = { 0, "cxcore", CV_VERSION, 0 }; - -CvModuleInfo* CvModule::first = 0, *CvModule::last = 0; - -CvModule::CvModule( CvModuleInfo* _info ) -{ - cvRegisterModule( _info ); - info = last; -} - -CvModule::~CvModule(void) -{ - if( info ) - { - CvModuleInfo* p = first; - for( ; p != 0 && p->next != info; p = p->next ) - ; - - if( p ) - p->next = info->next; - - if( first == info ) - first = info->next; - - if( last == info ) - last = p; - - free( info ); - info = 0; - } -} - -CV_IMPL int -cvRegisterModule( const CvModuleInfo* module ) -{ - CV_Assert( module != 0 && module->name != 0 && module->version != 0 ); - - size_t name_len = strlen(module->name); - size_t version_len = strlen(module->version); - - CvModuleInfo* module_copy = (CvModuleInfo*)malloc( sizeof(*module_copy) + - name_len + 1 + version_len + 1 ); - - *module_copy = *module; - module_copy->name = (char*)(module_copy + 1); - module_copy->version = (char*)(module_copy + 1) + name_len + 1; - - memcpy( (void*)module_copy->name, module->name, name_len + 1 ); - memcpy( (void*)module_copy->version, module->version, version_len + 1 ); - module_copy->next = 0; - - if( CvModule::first == 0 ) - CvModule::first = module_copy; - else - CvModule::last->next = module_copy; - - CvModule::last = module_copy; - - return 0; -} - -CvModule cxcore_module( &cxcore_info ); - -CV_IMPL void -cvGetModuleInfo( const char* name, const char **version, const char **plugin_list ) -{ - static char joint_verinfo[1024] = ""; - static char plugin_list_buf[1024] = ""; - - if( version ) - *version = 0; - - if( plugin_list ) - *plugin_list = 0; - - CvModuleInfo* module; - - if( version ) - { - if( name ) - { - size_t i, name_len = strlen(name); - - for( module = CvModule::first; module != 0; module = module->next ) - { - if( strlen(module->name) == name_len ) - { - for( i = 0; i < name_len; i++ ) - { - int c0 = toupper(module->name[i]), c1 = toupper(name[i]); - if( c0 != c1 ) - break; - } - if( i == name_len ) - break; - } - } - if( !module ) - CV_Error( CV_StsObjectNotFound, "The module is not found" ); - - *version = module->version; - } - else - { - char* ptr = joint_verinfo; - - for( module = CvModule::first; module != 0; module = module->next ) - { - sprintf( ptr, "%s: %s%s", module->name, module->version, module->next ? ", " : "" ); - ptr += strlen(ptr); - } - - *version = joint_verinfo; - } - } - - if( plugin_list ) - *plugin_list = plugin_list_buf; -} #if defined BUILD_SHARED_LIBS && defined CVAPI_EXPORTS && defined WIN32 && !defined WINCE BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID ); diff --git a/modules/legacy/include/opencv2/legacy/compat.hpp b/modules/legacy/include/opencv2/legacy/compat.hpp index 5b5495edcb..0af67d7537 100644 --- a/modules/legacy/include/opencv2/legacy/compat.hpp +++ b/modules/legacy/include/opencv2/legacy/compat.hpp @@ -56,6 +56,8 @@ #include #include +#define CV_NOOP(...) + #ifdef __cplusplus extern "C" { #endif @@ -190,7 +192,8 @@ CV_EXPORTS double cvPseudoInverse( const CvArr* src, CvArr* dst ); #define cvMinMaxLocMask(img, mask, min_val, max_val, min_loc, max_loc) \ cvMinMaxLoc(img, min_val, max_val, min_loc, max_loc, mask) -#define cvRemoveMemoryManager cvSetMemoryManager +#define cvRemoveMemoryManager CV_NOOP +#define cvSetMemoryManager CV_NOOP #define cvmSetZero( mat ) cvSetZero( mat ) #define cvmSetIdentity( mat ) cvSetIdentity( mat )