blob: 0283b529d22fc537b9ed81145fcb0bfb39337bc7 [file]
diff --git a/third_party/lcms/0000-cmserr-changes.patch b/third_party/lcms/0000-cmserr-changes.patch
index 13a854a29..e69de29bb 100644
--- a/third_party/lcms/0000-cmserr-changes.patch
+++ b/third_party/lcms/0000-cmserr-changes.patch
@@ -1,285 +0,0 @@
-diff --git a/third_party/lcms/src/cmserr.c b/third_party/lcms/src/cmserr.c
-index 700152ee3..3c3848b2a 100644
---- a/third_party/lcms/src/cmserr.c
-+++ b/third_party/lcms/src/cmserr.c
-@@ -25,6 +25,8 @@
-
- #include "lcms2_internal.h"
-
-+#include "core/fxcrt/fx_memory.h"
-+#include "core/fxcrt/fx_system.h"
-
- // This function is here to help applications to prevent mixing lcms versions on header and shared objects.
- int CMSEXPORT cmsGetEncodedCMMversion(void)
-@@ -67,140 +67,75 @@ long int CMSEXPORT cmsfilelength(FILE* f)
- return n;
- }
-
--
--// Memory handling ------------------------------------------------------------------
--//
--// This is the interface to low-level memory management routines. By default a simple
--// wrapping to malloc/free/realloc is provided, although there is a limit on the max
--// amount of memoy that can be reclaimed. This is mostly as a safety feature to prevent
--// bogus or evil code to allocate huge blocks that otherwise lcms would never need.
--
--#define MAX_MEMORY_FOR_ALLOC ((cmsUInt32Number)(1024U*1024U*512U))
--
--// User may override this behaviour by using a memory plug-in, which basically replaces
--// the default memory management functions. In this case, no check is performed and it
--// is up to the plug-in writer to keep in the safe side. There are only three functions
--// required to be implemented: malloc, realloc and free, although the user may want to
--// replace the optional mallocZero, calloc and dup as well.
--
--cmsBool _cmsRegisterMemHandlerPlugin(cmsContext ContextID, cmsPluginBase* Plugin);
--
--// *********************************************************************************
--
--// This is the default memory allocation function. It does a very coarse
--// check of amount of memory, just to prevent exploits
--static
--void* _cmsMallocDefaultFn(cmsContext ContextID, cmsUInt32Number size)
-+cmsBool _cmsRegisterMemHandlerPlugin(cmsContext ContextID, cmsPluginBase* Plugin)
- {
-- if (size > MAX_MEMORY_FOR_ALLOC) return NULL; // Never allow over maximum
--
-- return (void*) malloc(size);
-+ return TRUE;
-+}
-
-- cmsUNUSED_PARAMETER(ContextID);
-+// Generic allocate
-+void* CMSEXPORT _cmsMalloc(cmsContext ContextID, cmsUInt32Number size)
-+{
-+ return FXMEM_DefaultAlloc(size);
- }
-
- // Generic allocate & zero
--static
--void* _cmsMallocZeroDefaultFn(cmsContext ContextID, cmsUInt32Number size)
-+void* CMSEXPORT _cmsMallocZero(cmsContext ContextID, cmsUInt32Number size)
- {
-- void *pt = _cmsMalloc(ContextID, size);
-- if (pt == NULL) return NULL;
--
-- memset(pt, 0, size);
-- return pt;
-+ void* p = FXMEM_DefaultAlloc(size);
-+ if (p) memset(p, 0, size);
-+ return p;
- }
-
--
--// The default free function. The only check proformed is against NULL pointers
--static
--void _cmsFreeDefaultFn(cmsContext ContextID, void *Ptr)
-+// Generic calloc
-+void* CMSEXPORT _cmsCalloc(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size)
- {
-- // free(NULL) is defined a no-op by C99, therefore it is safe to
-- // avoid the check, but it is here just in case...
--
-- if (Ptr) free(Ptr);
-+ cmsUInt32Number total = num * size;
-+ if (total == 0 || total / size != num || total >= 512 * 1024 * 1024)
-+ return NULL;
-
-- cmsUNUSED_PARAMETER(ContextID);
-+ return _cmsMallocZero(ContextID, num * size);
- }
-
--// The default realloc function. Again it checks for exploits. If Ptr is NULL,
--// realloc behaves the same way as malloc and allocates a new block of size bytes.
--static
--void* _cmsReallocDefaultFn(cmsContext ContextID, void* Ptr, cmsUInt32Number size)
-+// Generic reallocate
-+void* CMSEXPORT _cmsRealloc(cmsContext ContextID, void* Ptr, cmsUInt32Number size)
- {
--
-- if (size > MAX_MEMORY_FOR_ALLOC) return NULL; // Never realloc over 512Mb
--
-- return realloc(Ptr, size);
--
-- cmsUNUSED_PARAMETER(ContextID);
-+ return FXMEM_DefaultRealloc(Ptr, size);
- }
-
--
--// The default calloc function. Allocates an array of num elements, each one of size bytes
--// all memory is initialized to zero.
--static
--void* _cmsCallocDefaultFn(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size)
-+// Generic free memory
-+void CMSEXPORT _cmsFree(cmsContext ContextID, void* Ptr)
- {
-- cmsUInt32Number Total = num * size;
--
-- // Preserve calloc behaviour
-- if (Total == 0) return NULL;
--
-- // Safe check for overflow.
-- if (num >= UINT_MAX / size) return NULL;
--
-- // Check for overflow
-- if (Total < num || Total < size) {
-- return NULL;
-- }
--
-- if (Total > MAX_MEMORY_FOR_ALLOC) return NULL; // Never alloc over 512Mb
--
-- return _cmsMallocZero(ContextID, Total);
-+ if (Ptr != NULL) FXMEM_DefaultFree(Ptr);
- }
-
- // Generic block duplication
--static
--void* _cmsDupDefaultFn(cmsContext ContextID, const void* Org, cmsUInt32Number size)
-+void* CMSEXPORT _cmsDupMem(cmsContext ContextID, const void* Org, cmsUInt32Number size)
- {
-- void* mem;
--
-- if (size > MAX_MEMORY_FOR_ALLOC) return NULL; // Never dup over 512Mb
--
-- mem = _cmsMalloc(ContextID, size);
--
-- if (mem != NULL && Org != NULL)
-- memmove(mem, Org, size);
--
-- return mem;
-+ void* p = FXMEM_DefaultAlloc(size);
-+ memmove(p, Org, size);
-+ return p;
- }
-
--
--// Pointers to memory manager functions in Context0
--_cmsMemPluginChunkType _cmsMemPluginChunk = { _cmsMallocDefaultFn, _cmsMallocZeroDefaultFn, _cmsFreeDefaultFn,
-- _cmsReallocDefaultFn, _cmsCallocDefaultFn, _cmsDupDefaultFn
-+_cmsMemPluginChunkType _cmsMemPluginChunk = {_cmsMalloc, _cmsMallocZero, _cmsFree,
-+ _cmsRealloc, _cmsCalloc, _cmsDupMem
- };
-
--
--// Reset and duplicate memory manager
- void _cmsAllocMemPluginChunk(struct _cmsContext_struct* ctx, const struct _cmsContext_struct* src)
- {
- _cmsAssert(ctx != NULL);
-
-- if (src != NULL) {
-+ if (src != NULL) {
-
- // Duplicate
-- ctx ->chunks[MemPlugin] = _cmsSubAllocDup(ctx ->MemPool, src ->chunks[MemPlugin], sizeof(_cmsMemPluginChunkType));
-+ ctx ->chunks[MemPlugin] = _cmsSubAllocDup(ctx ->MemPool, src ->chunks[MemPlugin], sizeof(_cmsMemPluginChunkType));
- }
- else {
-
- // To reset it, we use the default allocators, which cannot be overridden
- ctx ->chunks[MemPlugin] = &ctx ->DefaultMemoryManager;
-- }
-+ }
- }
-
--// Auxiliary to fill memory management functions from plugin (or context 0 defaults)
- void _cmsInstallAllocFunctions(cmsPluginMemHandler* Plugin, _cmsMemPluginChunkType* ptr)
- {
- if (Plugin == NULL) {
-@@ -214,94 +149,15 @@ void _cmsInstallAllocFunctions(cmsPluginMemHandler* Plugin, _cmsMemPluginChunkTy
- ptr ->ReallocPtr = Plugin -> ReallocPtr;
-
- // Make sure we revert to defaults
-- ptr ->MallocZeroPtr= _cmsMallocZeroDefaultFn;
-- ptr ->CallocPtr = _cmsCallocDefaultFn;
-- ptr ->DupPtr = _cmsDupDefaultFn;
--
-+ ptr ->MallocZeroPtr= _cmsMallocZero;
-+ ptr ->CallocPtr = _cmsCalloc;
-+ ptr ->DupPtr = _cmsDupMem;
-+
- if (Plugin ->MallocZeroPtr != NULL) ptr ->MallocZeroPtr = Plugin -> MallocZeroPtr;
- if (Plugin ->CallocPtr != NULL) ptr ->CallocPtr = Plugin -> CallocPtr;
- if (Plugin ->DupPtr != NULL) ptr ->DupPtr = Plugin -> DupPtr;
--
-- }
--}
--
-
--// Plug-in replacement entry
--cmsBool _cmsRegisterMemHandlerPlugin(cmsContext ContextID, cmsPluginBase *Data)
--{
-- cmsPluginMemHandler* Plugin = (cmsPluginMemHandler*) Data;
-- _cmsMemPluginChunkType* ptr;
--
-- // NULL forces to reset to defaults. In this special case, the defaults are stored in the context structure.
-- // Remaining plug-ins does NOT have any copy in the context structure, but this is somehow special as the
-- // context internal data should be malloce'd by using those functions.
-- if (Data == NULL) {
--
-- struct _cmsContext_struct* ctx = ( struct _cmsContext_struct*) ContextID;
--
-- // Return to the default allocators
-- if (ContextID != NULL) {
-- ctx->chunks[MemPlugin] = (void*) &ctx->DefaultMemoryManager;
-- }
-- return TRUE;
- }
--
-- // Check for required callbacks
-- if (Plugin -> MallocPtr == NULL ||
-- Plugin -> FreePtr == NULL ||
-- Plugin -> ReallocPtr == NULL) return FALSE;
--
-- // Set replacement functions
-- ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
-- if (ptr == NULL)
-- return FALSE;
--
-- _cmsInstallAllocFunctions(Plugin, ptr);
-- return TRUE;
--}
--
--// Generic allocate
--void* CMSEXPORT _cmsMalloc(cmsContext ContextID, cmsUInt32Number size)
--{
-- _cmsMemPluginChunkType* ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
-- return ptr ->MallocPtr(ContextID, size);
--}
--
--// Generic allocate & zero
--void* CMSEXPORT _cmsMallocZero(cmsContext ContextID, cmsUInt32Number size)
--{
-- _cmsMemPluginChunkType* ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
-- return ptr->MallocZeroPtr(ContextID, size);
--}
--
--// Generic calloc
--void* CMSEXPORT _cmsCalloc(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size)
--{
-- _cmsMemPluginChunkType* ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
-- return ptr->CallocPtr(ContextID, num, size);
--}
--
--// Generic reallocate
--void* CMSEXPORT _cmsRealloc(cmsContext ContextID, void* Ptr, cmsUInt32Number size)
--{
-- _cmsMemPluginChunkType* ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
-- return ptr->ReallocPtr(ContextID, Ptr, size);
--}
--
--// Generic free memory
--void CMSEXPORT _cmsFree(cmsContext ContextID, void* Ptr)
--{
-- if (Ptr != NULL) {
-- _cmsMemPluginChunkType* ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
-- ptr ->FreePtr(ContextID, Ptr);
-- }
--}
--
--// Generic block duplication
--void* CMSEXPORT _cmsDupMem(cmsContext ContextID, const void* Org, cmsUInt32Number size)
--{
-- _cmsMemPluginChunkType* ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
-- return ptr ->DupPtr(ContextID, Org, size);
- }
-
- // ********************************************************************************************
diff --git a/third_party/lcms/src/cmserr.c b/third_party/lcms/src/cmserr.c
index ac89811a9..902b7762a 100644
--- a/third_party/lcms/src/cmserr.c
+++ b/third_party/lcms/src/cmserr.c
@@ -1,7 +1,7 @@
//---------------------------------------------------------------------------------
//
// Little Color Management System
-// Copyright (c) 1998-2026 Marti Maria Saguer
+// Copyright (c) 1998-2023 Marti Maria Saguer
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the "Software"),
@@ -25,6 +25,8 @@
#include "lcms2_internal.h"
+#include "core/fxcrt/fx_memory.h"
+#include "core/fxcrt/fx_system.h"
// This function is here to help applications to prevent mixing lcms versions on header and shared objects.
int CMSEXPORT cmsGetEncodedCMMversion(void)
@@ -48,203 +50,94 @@ int CMSEXPORT cmsstrcasecmp(const char* s1, const char* s2)
return (toupper(*us1) - toupper(*--us2));
}
-#ifdef CMS_LARGE_FILE_SUPPORT
-
-long long int CMSEXPORT cmsfilelength(FILE* f)
-{
- long long int p, n;
-
-#ifdef CMS_IS_WINDOWS_
- p = _ftelli64(f);
- if (p == -1LL)
- return -1LL;
-
- if (_fseeki64(f, 0, SEEK_END) != 0)
- return -1LL;
-
- n = _ftelli64(f);
-
- if (_fseeki64(f, p, SEEK_SET) != 0)
- return -1LL;
-#else
- p = (long long int) ftello(f);
- if (p < 0)
- return -1LL;
-
- if (fseeko(f, 0, SEEK_END) != 0)
- return -1LL;
-
- n = (long long int) ftello(f);
-
- if (fseeko(f, (off_t) p, SEEK_SET) != 0)
- return -1LL;
-#endif
-
- return n;
-}
-
-#else
-
// long int because C99 specifies ftell in such way (7.19.9.2)
long int CMSEXPORT cmsfilelength(FILE* f)
{
- long int p, n;
+ long int p , n;
- p = ftell(f);
- if (p == -1L)
+ p = ftell(f); // register current file position
+ if (p == -1L)
return -1L;
- if (fseek(f, 0, SEEK_END) != 0)
+ if (fseek(f, 0, SEEK_END) != 0) {
return -1L;
+ }
n = ftell(f);
-
- if (fseek(f, p, SEEK_SET) != 0)
- return -1L;
+ fseek(f, p, SEEK_SET); // file position restored
return n;
}
-#endif
-
-// Memory handling ------------------------------------------------------------------
-//
-// This is the interface to low-level memory management routines. By default a simple
-// wrapping to malloc/free/realloc is provided, although there is a limit on the max
-// amount of memory that can be reclaimed. This is mostly as a safety feature to prevent
-// bogus or evil code to allocate huge blocks that otherwise lcms would never need.
-
-#ifdef CMS_LARGE_FILE_SUPPORT
-# define MAX_MEMORY_FOR_ALLOC ((cmsUInt32Number)(1024U*1024U*2048U))
-#else
-# define MAX_MEMORY_FOR_ALLOC ((cmsUInt32Number)(1024U*1024U*512U))
-#endif
-
-// User may override this behaviour by using a memory plug-in, which basically replaces
-// the default memory management functions. In this case, no check is performed and it
-// is up to the plug-in writer to keep in the safe side. There are only three functions
-// required to be implemented: malloc, realloc and free, although the user may want to
-// replace the optional mallocZero, calloc and dup as well.
-
-cmsBool _cmsRegisterMemHandlerPlugin(cmsContext ContextID, cmsPluginBase* Plugin);
-
-// *********************************************************************************
-
-// This is the default memory allocation function. It does a very coarse
-// check of amount of memory, just to prevent exploits
-static
-void* _cmsMallocDefaultFn(cmsContext ContextID, cmsUInt32Number size)
+cmsBool _cmsRegisterMemHandlerPlugin(cmsContext ContextID, cmsPluginBase* Plugin)
{
- // Never allow 0 or over maximum
- if (size == 0 || size > MAX_MEMORY_FOR_ALLOC) return NULL;
-
- return (void*) malloc(size);
+ return TRUE;
+}
- cmsUNUSED_PARAMETER(ContextID);
+// Generic allocate
+void* CMSEXPORT _cmsMalloc(cmsContext ContextID, cmsUInt32Number size)
+{
+ return FXMEM_DefaultAlloc(size);
}
// Generic allocate & zero
-static
-void* _cmsMallocZeroDefaultFn(cmsContext ContextID, cmsUInt32Number size)
+void* CMSEXPORT _cmsMallocZero(cmsContext ContextID, cmsUInt32Number size)
{
- void *pt = _cmsMalloc(ContextID, size);
- if (pt == NULL) return NULL;
-
- memset(pt, 0, size);
- return pt;
+ void* p = FXMEM_DefaultAlloc(size);
+ if (p) memset(p, 0, size);
+ return p;
}
-
-// The default free function. The only check proformed is against NULL pointers
-static
-void _cmsFreeDefaultFn(cmsContext ContextID, void *Ptr)
+// Generic calloc
+void* CMSEXPORT _cmsCalloc(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size)
{
- // free(NULL) is defined a no-op by C99, therefore it is safe to
- // avoid the check, but it is here just in case...
-
- if (Ptr) free(Ptr);
+ cmsUInt32Number total = num * size;
+ if (total == 0 || total / size != num || total >= 512 * 1024 * 1024)
+ return NULL;
- cmsUNUSED_PARAMETER(ContextID);
+ return _cmsMallocZero(ContextID, num * size);
}
-// The default realloc function. Again it checks for exploits. If Ptr is NULL,
-// realloc behaves the same way as malloc and allocates a new block of size bytes.
-static
-void* _cmsReallocDefaultFn(cmsContext ContextID, void* Ptr, cmsUInt32Number size)
+// Generic reallocate
+void* CMSEXPORT _cmsRealloc(cmsContext ContextID, void* Ptr, cmsUInt32Number size)
{
-
- if (size > MAX_MEMORY_FOR_ALLOC) return NULL; // Never realloc over 512Mb
-
- return realloc(Ptr, size);
-
- cmsUNUSED_PARAMETER(ContextID);
+ return FXMEM_DefaultRealloc(Ptr, size);
}
-
-// The default calloc function. Allocates an array of num elements, each one of size bytes
-// all memory is initialized to zero.
-static
-void* _cmsCallocDefaultFn(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size)
+// Generic free memory
+void CMSEXPORT _cmsFree(cmsContext ContextID, void* Ptr)
{
- cmsUInt32Number Total = num * size;
-
- // Preserve calloc behaviour
- if (Total == 0) return NULL;
-
- // Safe check for overflow.
- if (num >= UINT_MAX / size) return NULL;
-
- // Check for overflow
- if (Total < num || Total < size) {
- return NULL;
- }
-
- if (Total > MAX_MEMORY_FOR_ALLOC) return NULL; // Never alloc over 512Mb
-
- return _cmsMallocZero(ContextID, Total);
+ if (Ptr != NULL) FXMEM_DefaultFree(Ptr);
}
// Generic block duplication
-static
-void* _cmsDupDefaultFn(cmsContext ContextID, const void* Org, cmsUInt32Number size)
+void* CMSEXPORT _cmsDupMem(cmsContext ContextID, const void* Org, cmsUInt32Number size)
{
- void* mem;
-
- if (size > MAX_MEMORY_FOR_ALLOC) return NULL; // Never dup over 512Mb
-
- mem = _cmsMalloc(ContextID, size);
-
- if (mem != NULL && Org != NULL)
- memmove(mem, Org, size);
-
- return mem;
+ void* p = FXMEM_DefaultAlloc(size);
+ memmove(p, Org, size);
+ return p;
}
-
-// Pointers to memory manager functions in Context0
-_cmsMemPluginChunkType _cmsMemPluginChunk = { _cmsMallocDefaultFn, _cmsMallocZeroDefaultFn, _cmsFreeDefaultFn,
- _cmsReallocDefaultFn, _cmsCallocDefaultFn, _cmsDupDefaultFn
+_cmsMemPluginChunkType _cmsMemPluginChunk = {_cmsMalloc, _cmsMallocZero, _cmsFree,
+ _cmsRealloc, _cmsCalloc, _cmsDupMem
};
-
-// Reset and duplicate memory manager
void _cmsAllocMemPluginChunk(struct _cmsContext_struct* ctx, const struct _cmsContext_struct* src)
{
_cmsAssert(ctx != NULL);
- if (src != NULL) {
+ if (src != NULL) {
// Duplicate
- ctx ->chunks[MemPlugin] = _cmsSubAllocDup(ctx ->MemPool, src ->chunks[MemPlugin], sizeof(_cmsMemPluginChunkType));
+ ctx ->chunks[MemPlugin] = _cmsSubAllocDup(ctx ->MemPool, src ->chunks[MemPlugin], sizeof(_cmsMemPluginChunkType));
}
else {
// To reset it, we use the default allocators, which cannot be overridden
ctx ->chunks[MemPlugin] = &ctx ->DefaultMemoryManager;
- }
+ }
}
-// Auxiliary to fill memory management functions from plugin (or context 0 defaults)
void _cmsInstallAllocFunctions(cmsPluginMemHandler* Plugin, _cmsMemPluginChunkType* ptr)
{
if (Plugin == NULL) {
@@ -258,96 +151,17 @@ void _cmsInstallAllocFunctions(cmsPluginMemHandler* Plugin, _cmsMemPluginChunkTy
ptr ->ReallocPtr = Plugin -> ReallocPtr;
// Make sure we revert to defaults
- ptr ->MallocZeroPtr= _cmsMallocZeroDefaultFn;
- ptr ->CallocPtr = _cmsCallocDefaultFn;
- ptr ->DupPtr = _cmsDupDefaultFn;
-
+ ptr ->MallocZeroPtr= _cmsMallocZero;
+ ptr ->CallocPtr = _cmsCalloc;
+ ptr ->DupPtr = _cmsDupMem;
+
if (Plugin ->MallocZeroPtr != NULL) ptr ->MallocZeroPtr = Plugin -> MallocZeroPtr;
if (Plugin ->CallocPtr != NULL) ptr ->CallocPtr = Plugin -> CallocPtr;
if (Plugin ->DupPtr != NULL) ptr ->DupPtr = Plugin -> DupPtr;
-
- }
-}
-
-
-// Plug-in replacement entry
-cmsBool _cmsRegisterMemHandlerPlugin(cmsContext ContextID, cmsPluginBase *Data)
-{
- cmsPluginMemHandler* Plugin = (cmsPluginMemHandler*) Data;
- _cmsMemPluginChunkType* ptr;
-
- // NULL forces to reset to defaults. In this special case, the defaults are stored in the context structure.
- // Remaining plug-ins does NOT have any copy in the context structure, but this is somehow special as the
- // context internal data should be malloc'ed by using those functions.
- if (Data == NULL) {
-
- struct _cmsContext_struct* ctx = ( struct _cmsContext_struct*) ContextID;
-
- // Return to the default allocators
- if (ContextID != NULL) {
- ctx->chunks[MemPlugin] = (void*) &ctx->DefaultMemoryManager;
- }
- return TRUE;
- }
-
- // Check for required callbacks
- if (Plugin -> MallocPtr == NULL ||
- Plugin -> FreePtr == NULL ||
- Plugin -> ReallocPtr == NULL) return FALSE;
-
- // Set replacement functions
- ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
- if (ptr == NULL)
- return FALSE;
-
- _cmsInstallAllocFunctions(Plugin, ptr);
- return TRUE;
-}
-// Generic allocate
-void* CMSEXPORT _cmsMalloc(cmsContext ContextID, cmsUInt32Number size)
-{
- _cmsMemPluginChunkType* ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
- return ptr ->MallocPtr(ContextID, size);
-}
-
-// Generic allocate & zero
-void* CMSEXPORT _cmsMallocZero(cmsContext ContextID, cmsUInt32Number size)
-{
- _cmsMemPluginChunkType* ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
- return ptr->MallocZeroPtr(ContextID, size);
-}
-
-// Generic calloc
-void* CMSEXPORT _cmsCalloc(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size)
-{
- _cmsMemPluginChunkType* ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
- return ptr->CallocPtr(ContextID, num, size);
-}
-
-// Generic reallocate
-void* CMSEXPORT _cmsRealloc(cmsContext ContextID, void* Ptr, cmsUInt32Number size)
-{
- _cmsMemPluginChunkType* ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
- return ptr->ReallocPtr(ContextID, Ptr, size);
-}
-
-// Generic free memory
-void CMSEXPORT _cmsFree(cmsContext ContextID, void* Ptr)
-{
- if (Ptr != NULL) {
- _cmsMemPluginChunkType* ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
- ptr ->FreePtr(ContextID, Ptr);
}
}
-// Generic block duplication
-void* CMSEXPORT _cmsDupMem(cmsContext ContextID, const void* Org, cmsUInt32Number size)
-{
- _cmsMemPluginChunkType* ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlugin);
- return ptr ->DupPtr(ContextID, Org, size);
-}
-
// ********************************************************************************************
// Sub allocation takes care of many pointers of small size. The memory allocated in