diff options
-rw-r--r-- | src/cmsplugin.c | 22 | ||||
-rw-r--r-- | src/lcms2_internal.h | 2 | ||||
-rw-r--r-- | testbed/testthread.cpp | 4 | ||||
-rw-r--r-- | utils/psicc/psicc.c | 2 |
4 files changed, 18 insertions, 12 deletions
diff --git a/src/cmsplugin.c b/src/cmsplugin.c index 83e8336..317e33e 100644 --- a/src/cmsplugin.c +++ b/src/cmsplugin.c @@ -518,22 +518,28 @@ cmsBool CMSEXPORT _cmsIOPrintf(cmsIOHANDLER* io, const char* frm, ...) // Specialized malloc for plug-ins, that is freed upon exit. void* _cmsPluginMalloc(cmsContext ContextID, cmsUInt32Number size) { - struct _cmsContext_struct* ctx = _cmsGetContext(ContextID); + struct _cmsContext_struct* ctx = _cmsGetContext(ContextID); - if (ctx ->MemPool == NULL) { + if (ctx ->MemPool == NULL) { + + if (ContextID == NULL) { - cmsSignalError(ContextID, cmsERROR_CORRUPTION_DETECTED, "NULL memory pool on context"); - return NULL; - } + ctx->MemPool = _cmsCreateSubAlloc(0, 2*1024); + } + else { + cmsSignalError(ContextID, cmsERROR_CORRUPTION_DETECTED, "NULL memory pool on context"); + return NULL; + } + } - return _cmsSubAlloc(ctx->MemPool, size); + return _cmsSubAlloc(ctx->MemPool, size); } // Main plug-in dispatcher cmsBool CMSEXPORT cmsPlugin(void* Plug_in) { - return cmsPluginTHR(NULL, Plug_in); + return cmsPluginTHR(NULL, Plug_in); } cmsBool CMSEXPORT cmsPluginTHR(cmsContext id, void* Plug_in) @@ -769,7 +775,7 @@ cmsContext CMSEXPORT cmsCreateContext(void* Plugin, void* UserData) memcpy(&ctx->DefaultMemoryManager, &fakeContext.DefaultMemoryManager, sizeof(_cmsMemPluginChunk)); // Maintain the linked list (with proper locking) - _cmsEnterCriticalSectionPrimitive(&_cmsContextPoolHeadMutex); + _cmsEnterCriticalSectionPrimitive(&_cmsContextPoolHeadMutex); ctx ->Next = _cmsContextPoolHead; _cmsContextPoolHead = ctx; _cmsLeaveCriticalSectionPrimitive(&_cmsContextPoolHeadMutex); diff --git a/src/lcms2_internal.h b/src/lcms2_internal.h index 27b9352..b21b03e 100644 --- a/src/lcms2_internal.h +++ b/src/lcms2_internal.h @@ -198,7 +198,7 @@ cmsINLINE cmsUInt16Number _cmsQuickSaturateWord(cmsFloat64Number d) typedef CRITICAL_SECTION _cmsMutex; -#define CMS_MUTEX_INITIALIZER {((void*) (intptr_t) -1),-1,0,0,0,0} +#define CMS_MUTEX_INITIALIZER {(void*) -1,-1,0,0,0,0} cmsINLINE int _cmsLockPrimitive(_cmsMutex *m) { diff --git a/testbed/testthread.cpp b/testbed/testthread.cpp index d553567..b932761 100644 --- a/testbed/testthread.cpp +++ b/testbed/testthread.cpp @@ -50,7 +50,7 @@ static DWORD WINAPI one_thread(LPVOID lpParameter) Sleep(rand() % 500 ); cmsHTRANSFORM xform = cmsCreateTransformTHR(ctx, prof_rgb, TYPE_RGB_8, prof_cmyk, TYPE_CMYK_8, 0, 0); - for (i=0; i < 10000; i++) { + for (i=0; i < 100000; i++) { for (j=0; j < 1000; j++) { @@ -86,7 +86,7 @@ int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,i OutputDebugString(L"Test in progress...\n"); - ctx = cmsCreateContext(&MutexPluginSample, 0); + ctx = cmsCreateContext(NULL, 0); prof_cmyk = cmsOpenProfileFromFileTHR(ctx, "USWebCoatedSWOP.icc", "r"); prof_rgb = cmsOpenProfileFromFileTHR(ctx, "AdobeRGB1998.icc","r"); diff --git a/utils/psicc/psicc.c b/utils/psicc/psicc.c index 9d6a280..0a3c898 100644 --- a/utils/psicc/psicc.c +++ b/utils/psicc/psicc.c @@ -144,7 +144,7 @@ void GenerateCSA(void) Buffer = (char*) malloc(n + 1); if (Buffer != NULL) { - cmsGetPostScriptCSA(0, hProfile, Intent, 0, Buffer, n); + cmsGetPostScriptCSA(0, hProfile, Intent, 0, Buffer, (cmsUInt32Number) n); Buffer[n] = 0; fprintf(OutFile, "%s", Buffer); |