Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: third_party/lcms2-2.6/src/cmserr.c

Issue 1825953002: Move core/include/fxcrt to core/fxcrt/include. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/agg23/agg_vcgen_stroke.cpp ('k') | third_party/libjpeg/jinclude.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //------------------------------------------------------------------------------ --- 1 //------------------------------------------------------------------------------ ---
2 // 2 //
3 // Little Color Management System 3 // Little Color Management System
4 // Copyright (c) 1998-2012 Marti Maria Saguer 4 // Copyright (c) 1998-2012 Marti Maria Saguer
5 // 5 //
6 // Permission is hereby granted, free of charge, to any person obtaining 6 // Permission is hereby granted, free of charge, to any person obtaining
7 // a copy of this software and associated documentation files (the "Software"), 7 // a copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation 8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the Softwar e 10 // and/or sell copies of the Software, and to permit persons to whom the Softwar e
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 fseek(f, p, SEEK_SET); // file position restored 56 fseek(f, p, SEEK_SET); // file position restored
57 57
58 return n; 58 return n;
59 } 59 }
60 60
61 #if 0 61 #if 0
62 // Memory handling ------------------------------------------------------------- ----- 62 // Memory handling ------------------------------------------------------------- -----
63 // 63 //
64 // This is the interface to low-level memory management routines. By default a s imple 64 // This is the interface to low-level memory management routines. By default a s imple
65 // wrapping to malloc/free/realloc is provided, although there is a limit on the max 65 // wrapping to malloc/free/realloc is provided, although there is a limit on the max
66 // amount of memoy that can be reclaimed. This is mostly as a safety feature to prevent 66 // amount of memoy that can be reclaimed. This is mostly as a safety feature to prevent
67 // bogus or evil code to allocate huge blocks that otherwise lcms would never ne ed. 67 // bogus or evil code to allocate huge blocks that otherwise lcms would never ne ed.
68 68
69 #define MAX_MEMORY_FOR_ALLOC ((cmsUInt32Number)(1024U*1024U*512U)) 69 #define MAX_MEMORY_FOR_ALLOC ((cmsUInt32Number)(1024U*1024U*512U))
70 70
71 // User may override this behaviour by using a memory plug-in, which basically r eplaces 71 // User may override this behaviour by using a memory plug-in, which basically r eplaces
72 // the default memory management functions. In this case, no check is performed and it 72 // the default memory management functions. In this case, no check is performed and it
73 // is up to the plug-in writter to keep in the safe side. There are only three f unctions 73 // is up to the plug-in writter to keep in the safe side. There are only three f unctions
74 // required to be implemented: malloc, realloc and free, although the user may w ant to 74 // required to be implemented: malloc, realloc and free, although the user may w ant to
75 // replace the optional mallocZero, calloc and dup as well. 75 // replace the optional mallocZero, calloc and dup as well.
76 76
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 mem = _cmsMalloc(ContextID, size); 162 mem = _cmsMalloc(ContextID, size);
163 163
164 if (mem != NULL && Org != NULL) 164 if (mem != NULL && Org != NULL)
165 memmove(mem, Org, size); 165 memmove(mem, Org, size);
166 166
167 return mem; 167 return mem;
168 } 168 }
169 169
170 170
171 // Pointers to memory manager functions in Context0 171 // Pointers to memory manager functions in Context0
172 _cmsMemPluginChunkType _cmsMemPluginChunk = { _cmsMallocDefaultFn, _cmsMallocZer oDefaultFn, _cmsFreeDefaultFn, 172 _cmsMemPluginChunkType _cmsMemPluginChunk = { _cmsMallocDefaultFn, _cmsMallocZer oDefaultFn, _cmsFreeDefaultFn,
173 _cmsReallocDefaultFn, _cmsCallocDe faultFn, _cmsDupDefaultFn 173 _cmsReallocDefaultFn, _cmsCallocDe faultFn, _cmsDupDefaultFn
174 }; 174 };
175 175
176 176
177 // Reset and duplicate memory manager 177 // Reset and duplicate memory manager
178 void _cmsAllocMemPluginChunk(struct _cmsContext_struct* ctx, const struct _cmsCo ntext_struct* src) 178 void _cmsAllocMemPluginChunk(struct _cmsContext_struct* ctx, const struct _cmsCo ntext_struct* src)
179 { 179 {
180 _cmsAssert(ctx != NULL); 180 _cmsAssert(ctx != NULL);
181 181
182 if (src != NULL) { 182 if (src != NULL) {
183 183
184 // Duplicate 184 // Duplicate
185 ctx ->chunks[MemPlugin] = _cmsSubAllocDup(ctx ->MemPool, src ->chunks[Me mPlugin], sizeof(_cmsMemPluginChunkType)); 185 ctx ->chunks[MemPlugin] = _cmsSubAllocDup(ctx ->MemPool, src ->chunks[Me mPlugin], sizeof(_cmsMemPluginChunkType));
186 } 186 }
187 else { 187 else {
188 188
189 // To reset it, we use the default allocators, which cannot be overriden 189 // To reset it, we use the default allocators, which cannot be overriden
190 ctx ->chunks[MemPlugin] = &ctx ->DefaultMemoryManager; 190 ctx ->chunks[MemPlugin] = &ctx ->DefaultMemoryManager;
191 } 191 }
192 } 192 }
193 193
194 // Auxiliar to fill memory management functions from plugin (or context 0 defaul ts) 194 // Auxiliar to fill memory management functions from plugin (or context 0 defaul ts)
195 void _cmsInstallAllocFunctions(cmsPluginMemHandler* Plugin, _cmsMemPluginChunkTy pe* ptr) 195 void _cmsInstallAllocFunctions(cmsPluginMemHandler* Plugin, _cmsMemPluginChunkTy pe* ptr)
196 { 196 {
197 if (Plugin == NULL) { 197 if (Plugin == NULL) {
198 198
199 memcpy(ptr, &_cmsMemPluginChunk, sizeof(_cmsMemPluginChunk)); 199 memcpy(ptr, &_cmsMemPluginChunk, sizeof(_cmsMemPluginChunk));
200 } 200 }
201 else { 201 else {
202 202
203 ptr ->MallocPtr = Plugin -> MallocPtr; 203 ptr ->MallocPtr = Plugin -> MallocPtr;
204 ptr ->FreePtr = Plugin -> FreePtr; 204 ptr ->FreePtr = Plugin -> FreePtr;
205 ptr ->ReallocPtr = Plugin -> ReallocPtr; 205 ptr ->ReallocPtr = Plugin -> ReallocPtr;
206 206
207 // Make sure we revert to defaults 207 // Make sure we revert to defaults
208 ptr ->MallocZeroPtr= _cmsMallocZeroDefaultFn; 208 ptr ->MallocZeroPtr= _cmsMallocZeroDefaultFn;
209 ptr ->CallocPtr = _cmsCallocDefaultFn; 209 ptr ->CallocPtr = _cmsCallocDefaultFn;
210 ptr ->DupPtr = _cmsDupDefaultFn; 210 ptr ->DupPtr = _cmsDupDefaultFn;
211 211
212 if (Plugin ->MallocZeroPtr != NULL) ptr ->MallocZeroPtr = Plugin -> Mall ocZeroPtr; 212 if (Plugin ->MallocZeroPtr != NULL) ptr ->MallocZeroPtr = Plugin -> Mall ocZeroPtr;
213 if (Plugin ->CallocPtr != NULL) ptr ->CallocPtr = Plugin -> Call ocPtr; 213 if (Plugin ->CallocPtr != NULL) ptr ->CallocPtr = Plugin -> Call ocPtr;
214 if (Plugin ->DupPtr != NULL) ptr ->DupPtr = Plugin -> DupP tr; 214 if (Plugin ->DupPtr != NULL) ptr ->DupPtr = Plugin -> DupP tr;
215 215
216 } 216 }
217 } 217 }
218 218
219 219
220 // Plug-in replacement entry 220 // Plug-in replacement entry
221 cmsBool _cmsRegisterMemHandlerPlugin(cmsContext ContextID, cmsPluginBase *Data) 221 cmsBool _cmsRegisterMemHandlerPlugin(cmsContext ContextID, cmsPluginBase *Data)
222 { 222 {
223 cmsPluginMemHandler* Plugin = (cmsPluginMemHandler*) Data; 223 cmsPluginMemHandler* Plugin = (cmsPluginMemHandler*) Data;
224 _cmsMemPluginChunkType* ptr; 224 _cmsMemPluginChunkType* ptr;
225 225
226 // NULL forces to reset to defaults. In this special case, the defaults are stored in the context structure. 226 // NULL forces to reset to defaults. In this special case, the defaults are stored in the context structure.
227 // Remaining plug-ins does NOT have any copy in the context structure, but t his is somehow special as the 227 // Remaining plug-ins does NOT have any copy in the context structure, but t his is somehow special as the
228 // context internal data should be malloce'd by using those functions. 228 // context internal data should be malloce'd by using those functions.
229 if (Data == NULL) { 229 if (Data == NULL) {
230 230
231 struct _cmsContext_struct* ctx = ( struct _cmsContext_struct*) ContextID; 231 struct _cmsContext_struct* ctx = ( struct _cmsContext_struct*) ContextID;
232 232
233 // Return to the default allocators 233 // Return to the default allocators
234 if (ContextID != NULL) { 234 if (ContextID != NULL) {
235 ctx->chunks[MemPlugin] = (void*) &ctx->DefaultMemoryManager; 235 ctx->chunks[MemPlugin] = (void*) &ctx->DefaultMemoryManager;
236 } 236 }
237 return TRUE; 237 return TRUE;
238 } 238 }
239 239
240 // Check for required callbacks 240 // Check for required callbacks
241 if (Plugin -> MallocPtr == NULL || 241 if (Plugin -> MallocPtr == NULL ||
242 Plugin -> FreePtr == NULL || 242 Plugin -> FreePtr == NULL ||
243 Plugin -> ReallocPtr == NULL) return FALSE; 243 Plugin -> ReallocPtr == NULL) return FALSE;
244 244
245 // Set replacement functions 245 // Set replacement functions
246 ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlug in); 246 ptr = (_cmsMemPluginChunkType*) _cmsContextGetClientChunk(ContextID, MemPlug in);
247 if (ptr == NULL) 247 if (ptr == NULL)
248 return FALSE; 248 return FALSE;
249 249
250 _cmsInstallAllocFunctions(Plugin, ptr); 250 _cmsInstallAllocFunctions(Plugin, ptr);
251 return TRUE; 251 return TRUE;
252 } 252 }
253 #else 253 #else
254 #include "core/include/fxcrt/fx_memory.h" 254 #include "core/fxcrt/include/fx_memory.h"
255 #include "core/include/fxcrt/fx_system.h" 255 #include "core/fxcrt/include/fx_system.h"
256 256
257 cmsBool _cmsRegisterMemHandlerPlugin(cmsContext ContextID, cmsPluginBase* Plugi n) 257 cmsBool _cmsRegisterMemHandlerPlugin(cmsContext ContextID, cmsPluginBase* Plugi n)
258 { 258 {
259 return TRUE; 259 return TRUE;
260 } 260 }
261 261
262 // Generic allocate 262 // Generic allocate
263 void* CMSEXPORT _cmsMalloc(cmsContext ContextID, cmsUInt32Number size) 263 void* CMSEXPORT _cmsMalloc(cmsContext ContextID, cmsUInt32Number size)
264 { 264 {
265 return FXMEM_DefaultAlloc(size, 1); 265 return FXMEM_DefaultAlloc(size, 1);
(...skipping 30 matching lines...) Expand all
296 } 296 }
297 297
298 // Generic block duplication 298 // Generic block duplication
299 void* CMSEXPORT _cmsDupMem(cmsContext ContextID, const void* Org, cmsUInt32Numbe r size) 299 void* CMSEXPORT _cmsDupMem(cmsContext ContextID, const void* Org, cmsUInt32Numbe r size)
300 { 300 {
301 void* p = FXMEM_DefaultAlloc(size, 1); 301 void* p = FXMEM_DefaultAlloc(size, 1);
302 FXSYS_memmove(p, Org, size); 302 FXSYS_memmove(p, Org, size);
303 return p; 303 return p;
304 } 304 }
305 305
306 _cmsMemPluginChunkType _cmsMemPluginChunk = {_cmsMalloc, _cmsMallocZero, _cmsFre e, 306 _cmsMemPluginChunkType _cmsMemPluginChunk = {_cmsMalloc, _cmsMallocZero, _cmsFre e,
307 _cmsRealloc, _cmsCalloc, _cm sDupMem 307 _cmsRealloc, _cmsCalloc, _cm sDupMem
308 }; 308 };
309 309
310 void _cmsAllocMemPluginChunk(struct _cmsContext_struct* ctx, const struct _cmsCo ntext_struct* src) 310 void _cmsAllocMemPluginChunk(struct _cmsContext_struct* ctx, const struct _cmsCo ntext_struct* src)
311 { 311 {
312 _cmsAssert(ctx != NULL); 312 _cmsAssert(ctx != NULL);
313 313
314 » if (src != NULL) { 314 » if (src != NULL) {
315 315
316 // Duplicate 316 // Duplicate
317 » » ctx ->chunks[MemPlugin] = _cmsSubAllocDup(ctx ->MemPool, src ->c hunks[MemPlugin], sizeof(_cmsMemPluginChunkType)); 317 » » ctx ->chunks[MemPlugin] = _cmsSubAllocDup(ctx ->MemPool, src ->c hunks[MemPlugin], sizeof(_cmsMemPluginChunkType));
318 } 318 }
319 else { 319 else {
320 320
321 // To reset it, we use the default allocators, which cannot be o verriden 321 // To reset it, we use the default allocators, which cannot be o verriden
322 ctx ->chunks[MemPlugin] = &ctx ->DefaultMemoryManager; 322 ctx ->chunks[MemPlugin] = &ctx ->DefaultMemoryManager;
323 » } 323 » }
324 } 324 }
325 325
326 void _cmsInstallAllocFunctions(cmsPluginMemHandler* Plugin, _cmsMemPluginChunkTy pe* ptr) 326 void _cmsInstallAllocFunctions(cmsPluginMemHandler* Plugin, _cmsMemPluginChunkTy pe* ptr)
327 { 327 {
328 if (Plugin == NULL) { 328 if (Plugin == NULL) {
329 329
330 memcpy(ptr, &_cmsMemPluginChunk, sizeof(_cmsMemPluginChunk)); 330 memcpy(ptr, &_cmsMemPluginChunk, sizeof(_cmsMemPluginChunk));
331 } 331 }
332 else { 332 else {
333 333
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 ptr = sub -> h ->Block + sub -> h ->Used; 451 ptr = sub -> h ->Block + sub -> h ->Used;
452 sub -> h -> Used += size; 452 sub -> h -> Used += size;
453 453
454 return (void*) ptr; 454 return (void*) ptr;
455 } 455 }
456 456
457 // Duplicate in pool 457 // Duplicate in pool
458 void* _cmsSubAllocDup(_cmsSubAllocator* s, const void *ptr, cmsUInt32Number size ) 458 void* _cmsSubAllocDup(_cmsSubAllocator* s, const void *ptr, cmsUInt32Number size )
459 { 459 {
460 void *NewPtr; 460 void *NewPtr;
461 461
462 // Dup of null pointer is also NULL 462 // Dup of null pointer is also NULL
463 if (ptr == NULL) 463 if (ptr == NULL)
464 return NULL; 464 return NULL;
465 465
466 NewPtr = _cmsSubAlloc(s, size); 466 NewPtr = _cmsSubAlloc(s, size);
467 467
468 if (ptr != NULL && NewPtr != NULL) { 468 if (ptr != NULL && NewPtr != NULL) {
469 memcpy(NewPtr, ptr, size); 469 memcpy(NewPtr, ptr, size);
470 } 470 }
471 471
(...skipping 21 matching lines...) Expand all
493 // ----------------------------------------------------------------------------- ---------------------------- 493 // ----------------------------------------------------------------------------- ----------------------------
494 494
495 // This is our default log error 495 // This is our default log error
496 static void DefaultLogErrorHandlerFunction(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *Text); 496 static void DefaultLogErrorHandlerFunction(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *Text);
497 497
498 // Context0 storage, which is global 498 // Context0 storage, which is global
499 _cmsLogErrorChunkType _cmsLogErrorChunk = { DefaultLogErrorHandlerFunction }; 499 _cmsLogErrorChunkType _cmsLogErrorChunk = { DefaultLogErrorHandlerFunction };
500 500
501 // Allocates and inits error logger container for a given context. If src is NUL L, only initializes the value 501 // Allocates and inits error logger container for a given context. If src is NUL L, only initializes the value
502 // to the default. Otherwise, it duplicates the value. The interface is standard across all context clients 502 // to the default. Otherwise, it duplicates the value. The interface is standard across all context clients
503 void _cmsAllocLogErrorChunk(struct _cmsContext_struct* ctx, 503 void _cmsAllocLogErrorChunk(struct _cmsContext_struct* ctx,
504 const struct _cmsContext_struct* src) 504 const struct _cmsContext_struct* src)
505 { 505 {
506 static _cmsLogErrorChunkType LogErrorChunk = { DefaultLogErrorHandlerFunctio n }; 506 static _cmsLogErrorChunkType LogErrorChunk = { DefaultLogErrorHandlerFunctio n };
507 void* from; 507 void* from;
508 508
509 if (src != NULL) { 509 if (src != NULL) {
510 from = src ->chunks[Logger]; 510 from = src ->chunks[Logger];
511 } 511 }
512 else { 512 else {
513 from = &LogErrorChunk; 513 from = &LogErrorChunk;
514 } 514 }
515 515
516 ctx ->chunks[Logger] = _cmsSubAllocDup(ctx ->MemPool, from, sizeof(_cmsLogEr rorChunkType)); 516 ctx ->chunks[Logger] = _cmsSubAllocDup(ctx ->MemPool, from, sizeof(_cmsLogEr rorChunkType));
517 } 517 }
518 518
519 // The default error logger does nothing. 519 // The default error logger does nothing.
520 static 520 static
521 void DefaultLogErrorHandlerFunction(cmsContext ContextID, cmsUInt32Number ErrorC ode, const char *Text) 521 void DefaultLogErrorHandlerFunction(cmsContext ContextID, cmsUInt32Number ErrorC ode, const char *Text)
522 { 522 {
523 // fprintf(stderr, "[lcms]: %s\n", Text); 523 // fprintf(stderr, "[lcms]: %s\n", Text);
524 // fflush(stderr); 524 // fflush(stderr);
525 525
526 cmsUNUSED_PARAMETER(ContextID); 526 cmsUNUSED_PARAMETER(ContextID);
(...skipping 11 matching lines...) Expand all
538 if (Fn == NULL) 538 if (Fn == NULL)
539 lhg -> LogErrorHandler = DefaultLogErrorHandlerFunction; 539 lhg -> LogErrorHandler = DefaultLogErrorHandlerFunction;
540 else 540 else
541 lhg -> LogErrorHandler = Fn; 541 lhg -> LogErrorHandler = Fn;
542 } 542 }
543 } 543 }
544 544
545 // Change log error, legacy 545 // Change log error, legacy
546 void CMSEXPORT cmsSetLogErrorHandler(cmsLogErrorHandlerFunction Fn) 546 void CMSEXPORT cmsSetLogErrorHandler(cmsLogErrorHandlerFunction Fn)
547 { 547 {
548 cmsSetLogErrorHandlerTHR(NULL, Fn); 548 cmsSetLogErrorHandlerTHR(NULL, Fn);
549 } 549 }
550 550
551 // Log an error 551 // Log an error
552 // ErrorText is a text holding an english description of error. 552 // ErrorText is a text holding an english description of error.
553 void CMSEXPORT cmsSignalError(cmsContext ContextID, cmsUInt32Number ErrorCode, c onst char *ErrorText, ...) 553 void CMSEXPORT cmsSignalError(cmsContext ContextID, cmsUInt32Number ErrorCode, c onst char *ErrorText, ...)
554 { 554 {
555 va_list args; 555 va_list args;
556 char Buffer[MAX_ERROR_MESSAGE_LEN]; 556 char Buffer[MAX_ERROR_MESSAGE_LEN];
557 _cmsLogErrorChunkType* lhg; 557 _cmsLogErrorChunkType* lhg;
558 558
559 559
560 va_start(args, ErrorText); 560 va_start(args, ErrorText);
561 vsnprintf(Buffer, MAX_ERROR_MESSAGE_LEN-1, ErrorText, args); 561 vsnprintf(Buffer, MAX_ERROR_MESSAGE_LEN-1, ErrorText, args);
562 va_end(args); 562 va_end(args);
563 563
564 // Check for the context, if specified go there. If not, go for the global 564 // Check for the context, if specified go there. If not, go for the global
565 lhg = (_cmsLogErrorChunkType*) _cmsContextGetClientChunk(ContextID, Logger); 565 lhg = (_cmsLogErrorChunkType*) _cmsContextGetClientChunk(ContextID, Logger);
566 if (lhg ->LogErrorHandler) { 566 if (lhg ->LogErrorHandler) {
567 lhg ->LogErrorHandler(ContextID, ErrorCode, Buffer); 567 lhg ->LogErrorHandler(ContextID, ErrorCode, Buffer);
568 } 568 }
569 } 569 }
570 570
571 // Utility function to print signatures 571 // Utility function to print signatures
572 void _cmsTagSignature2String(char String[5], cmsTagSignature sig) 572 void _cmsTagSignature2String(char String[5], cmsTagSignature sig)
573 { 573 {
574 cmsUInt32Number be; 574 cmsUInt32Number be;
575 575
576 // Convert to big endian 576 // Convert to big endian
577 be = _cmsAdjustEndianess32((cmsUInt32Number) sig); 577 be = _cmsAdjustEndianess32((cmsUInt32Number) sig);
578 578
579 // Move chars 579 // Move chars
580 memmove(String, &be, 4); 580 memmove(String, &be, 4);
581 581
582 // Make sure of terminator 582 // Make sure of terminator
583 String[4] = 0; 583 String[4] = 0;
584 } 584 }
585 585
586 //------------------------------------------------------------------------------ -------------------- 586 //------------------------------------------------------------------------------ --------------------
587 587
588 588
589 static 589 static
590 void* defMtxCreate(cmsContext id) 590 void* defMtxCreate(cmsContext id)
591 { 591 {
592 _cmsMutex* ptr_mutex = (_cmsMutex*) _cmsMalloc(id, sizeof(_cmsMutex)); 592 _cmsMutex* ptr_mutex = (_cmsMutex*) _cmsMalloc(id, sizeof(_cmsMutex));
593 _cmsInitMutexPrimitive(ptr_mutex); 593 _cmsInitMutexPrimitive(ptr_mutex);
594 return (void*) ptr_mutex; 594 return (void*) ptr_mutex;
595 } 595 }
596 596
597 static 597 static
598 void defMtxDestroy(cmsContext id, void* mtx) 598 void defMtxDestroy(cmsContext id, void* mtx)
599 { 599 {
600 _cmsDestroyMutexPrimitive((_cmsMutex *) mtx); 600 _cmsDestroyMutexPrimitive((_cmsMutex *) mtx);
601 _cmsFree(id, mtx); 601 _cmsFree(id, mtx);
602 } 602 }
603 603
604 static 604 static
605 cmsBool defMtxLock(cmsContext id, void* mtx) 605 cmsBool defMtxLock(cmsContext id, void* mtx)
606 { 606 {
607 cmsUNUSED_PARAMETER(id); 607 cmsUNUSED_PARAMETER(id);
608 return _cmsLockPrimitive((_cmsMutex *) mtx) == 0; 608 return _cmsLockPrimitive((_cmsMutex *) mtx) == 0;
609 } 609 }
610 610
611 static 611 static
612 void defMtxUnlock(cmsContext id, void* mtx) 612 void defMtxUnlock(cmsContext id, void* mtx)
613 { 613 {
614 cmsUNUSED_PARAMETER(id); 614 cmsUNUSED_PARAMETER(id);
615 _cmsUnlockPrimitive((_cmsMutex *) mtx); 615 _cmsUnlockPrimitive((_cmsMutex *) mtx);
616 } 616 }
617 617
618 618
619 619
620 // Pointers to memory manager functions in Context0 620 // Pointers to memory manager functions in Context0
621 _cmsMutexPluginChunkType _cmsMutexPluginChunk = { defMtxCreate, defMtxDestroy, d efMtxLock, defMtxUnlock }; 621 _cmsMutexPluginChunkType _cmsMutexPluginChunk = { defMtxCreate, defMtxDestroy, d efMtxLock, defMtxUnlock };
622 622
623 // Allocate and init mutex container. 623 // Allocate and init mutex container.
624 void _cmsAllocMutexPluginChunk(struct _cmsContext_struct* ctx, 624 void _cmsAllocMutexPluginChunk(struct _cmsContext_struct* ctx,
625 const struct _cmsContext_struct* src) 625 const struct _cmsContext_struct* src)
626 { 626 {
627 static _cmsMutexPluginChunkType MutexChunk = {defMtxCreate, defMtxDestroy, d efMtxLock, defMtxUnlock }; 627 static _cmsMutexPluginChunkType MutexChunk = {defMtxCreate, defMtxDestroy, d efMtxLock, defMtxUnlock };
628 void* from; 628 void* from;
629 629
630 if (src != NULL) { 630 if (src != NULL) {
631 from = src ->chunks[MutexPlugin]; 631 from = src ->chunks[MutexPlugin];
632 } 632 }
633 else { 633 else {
634 from = &MutexChunk; 634 from = &MutexChunk;
635 } 635 }
636 636
637 ctx ->chunks[MutexPlugin] = _cmsSubAllocDup(ctx ->MemPool, from, sizeof(_cms MutexPluginChunkType)); 637 ctx ->chunks[MutexPlugin] = _cmsSubAllocDup(ctx ->MemPool, from, sizeof(_cms MutexPluginChunkType));
638 } 638 }
639 639
640 // Register new ways to transform 640 // Register new ways to transform
641 cmsBool _cmsRegisterMutexPlugin(cmsContext ContextID, cmsPluginBase* Data) 641 cmsBool _cmsRegisterMutexPlugin(cmsContext ContextID, cmsPluginBase* Data)
642 { 642 {
643 cmsPluginMutex* Plugin = (cmsPluginMutex*) Data; 643 cmsPluginMutex* Plugin = (cmsPluginMutex*) Data;
644 _cmsMutexPluginChunkType* ctx = ( _cmsMutexPluginChunkType*) _cmsContextGetC lientChunk(ContextID, MutexPlugin); 644 _cmsMutexPluginChunkType* ctx = ( _cmsMutexPluginChunkType*) _cmsContextGetC lientChunk(ContextID, MutexPlugin);
645 645
646 if (Data == NULL) { 646 if (Data == NULL) {
647 647
648 // No lock routines 648 // No lock routines
649 ctx->CreateMutexPtr = NULL; 649 ctx->CreateMutexPtr = NULL;
650 ctx->DestroyMutexPtr = NULL; 650 ctx->DestroyMutexPtr = NULL;
651 ctx->LockMutexPtr = NULL; 651 ctx->LockMutexPtr = NULL;
652 ctx ->UnlockMutexPtr = NULL; 652 ctx ->UnlockMutexPtr = NULL;
653 return TRUE; 653 return TRUE;
654 } 654 }
655 655
656 // Factory callback is required 656 // Factory callback is required
657 if (Plugin ->CreateMutexPtr == NULL || Plugin ->DestroyMutexPtr == NULL || 657 if (Plugin ->CreateMutexPtr == NULL || Plugin ->DestroyMutexPtr == NULL ||
658 Plugin ->LockMutexPtr == NULL || Plugin ->UnlockMutexPtr == NULL) return FALSE; 658 Plugin ->LockMutexPtr == NULL || Plugin ->UnlockMutexPtr == NULL) return FALSE;
659 659
660 660
661 ctx->CreateMutexPtr = Plugin->CreateMutexPtr; 661 ctx->CreateMutexPtr = Plugin->CreateMutexPtr;
662 ctx->DestroyMutexPtr = Plugin ->DestroyMutexPtr; 662 ctx->DestroyMutexPtr = Plugin ->DestroyMutexPtr;
663 ctx ->LockMutexPtr = Plugin ->LockMutexPtr; 663 ctx ->LockMutexPtr = Plugin ->LockMutexPtr;
664 ctx ->UnlockMutexPtr = Plugin ->UnlockMutexPtr; 664 ctx ->UnlockMutexPtr = Plugin ->UnlockMutexPtr;
665 665
666 // All is ok 666 // All is ok
667 return TRUE; 667 return TRUE;
(...skipping 30 matching lines...) Expand all
698 698
699 void CMSEXPORT _cmsUnlockMutex(cmsContext ContextID, void* mtx) 699 void CMSEXPORT _cmsUnlockMutex(cmsContext ContextID, void* mtx)
700 { 700 {
701 _cmsMutexPluginChunkType* ptr = (_cmsMutexPluginChunkType*) _cmsContextGetCl ientChunk(ContextID, MutexPlugin); 701 _cmsMutexPluginChunkType* ptr = (_cmsMutexPluginChunkType*) _cmsContextGetCl ientChunk(ContextID, MutexPlugin);
702 702
703 if (ptr ->UnlockMutexPtr != NULL) { 703 if (ptr ->UnlockMutexPtr != NULL) {
704 704
705 ptr ->UnlockMutexPtr(ContextID, mtx); 705 ptr ->UnlockMutexPtr(ContextID, mtx);
706 } 706 }
707 } 707 }
OLDNEW
« no previous file with comments | « third_party/agg23/agg_vcgen_stroke.cpp ('k') | third_party/libjpeg/jinclude.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698