Drop CvModule and cvSetMemoryManager

pull/747/head
Andrey Kamaev 12 years ago
parent db45e04d58
commit 6bf49d49e7
  1. 34
      modules/core/include/opencv2/core/core_c.h
  2. 5
      modules/core/src/alloc.cpp
  3. 119
      modules/core/src/system.cpp
  4. 5
      modules/legacy/include/opencv2/legacy/compat.hpp

@ -1478,27 +1478,9 @@ CVAPI(int) cvKMeans2( const CvArr* samples, int cluster_count, CvArr* labels,
* System functions * * 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 */ /* Loads optimized functions from IPP, MKL etc. or switches back to pure C code */
CVAPI(int) cvUseOptimized( int on_off ); 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) typedef IplImage* (CV_STDCALL* Cv_iplCreateImageHeader)
(int,int,int,char*,char*,int,int,int,int,int, (int,int,int,char*,char*,int,int,int,int,int,
IplROI*,IplImage*,void*,IplTileInfo*); IplROI*,IplImage*,void*,IplTileInfo*);
@ -1843,19 +1825,11 @@ static char cvFuncName[] = Name
#define __CV_EXIT__ goto exit #define __CV_EXIT__ goto exit
#ifdef __cplusplus #ifdef __cplusplus
} } // extern "C"
#endif
// classes for automatic module/RTTI data registration/unregistration
struct CV_EXPORTS CvModule
{
CvModule( CvModuleInfo* _info );
~CvModule();
CvModuleInfo* info;
static CvModuleInfo* first;
static CvModuleInfo* last;
};
#ifdef __cplusplus
// class for automatic module/RTTI data registration/unregistration
struct CV_EXPORTS CvType struct CV_EXPORTS CvType
{ {
CvType( const char* type_name, CvType( const char* type_name,

@ -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 ) CV_IMPL void* cvAlloc( size_t size )
{ {
return cv::fastMalloc( size ); return cv::fastMalloc( size );

@ -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 #if defined BUILD_SHARED_LIBS && defined CVAPI_EXPORTS && defined WIN32 && !defined WINCE
BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID ); BOOL WINAPI DllMain( HINSTANCE, DWORD fdwReason, LPVOID );

@ -56,6 +56,8 @@
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#define CV_NOOP(...)
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #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) \ #define cvMinMaxLocMask(img, mask, min_val, max_val, min_loc, max_loc) \
cvMinMaxLoc(img, min_val, max_val, min_loc, max_loc, mask) 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 cvmSetZero( mat ) cvSetZero( mat )
#define cvmSetIdentity( mat ) cvSetIdentity( mat ) #define cvmSetIdentity( mat ) cvSetIdentity( mat )

Loading…
Cancel
Save