summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarti Maria <info@littlecms.com>2011-11-02 12:18:23 +0100
committerMarti Maria <info@littlecms.com>2011-11-02 12:18:23 +0100
commitb5c339c1527acc6d14ca86055e4a4081cc4fb00e (patch)
tree8424649b9a7f99417b319ed25549e61cf406f489
parent8385449504700f6ffc9f7efd1c132f5ea42cd2fa (diff)
downloadlcms2-b5c339c1527acc6d14ca86055e4a4081cc4fb00e.tar.gz
Memory alignment macro for CGATS parserlcms2.3rc2
-rw-r--r--AUTHORS1
-rw-r--r--ChangeLog2
-rw-r--r--src/cmscgats.c4
-rw-r--r--src/cmserr.c2
-rw-r--r--src/cmsplugin.c10
-rw-r--r--src/lcms2_internal.h8
6 files changed, 15 insertions, 12 deletions
diff --git a/AUTHORS b/AUTHORS
index d0a338c..ffac189 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -19,6 +19,7 @@ Shawn Pedersen
Andrew Brygin
Samuli Suominen
Florian Höch
+Aurelien Jarno
Special Thanks
--------------
diff --git a/ChangeLog b/ChangeLog
index 48dd267..c854fbc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -50,4 +50,4 @@ Fixed a 0 byte allocation issue in _cmsCreateSubAllocChunk
Fixed encoding for floating point tags in Lab/XYZ
Fixed Absolute colorimetric intent issues
Fixed a bug on the range of data in transicc, when colorant tag is specified
-
+Adding a memory alignment macro for CGATS parser
diff --git a/src/cmscgats.c b/src/cmscgats.c
index e5124ec..c096905 100644
--- a/src/cmscgats.c
+++ b/src/cmscgats.c
@@ -1,7 +1,7 @@
//---------------------------------------------------------------------------------
//
// Little Color Management System
-// Copyright (c) 1998-2010 Marti Maria Saguer
+// Copyright (c) 1998-2011 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"),
@@ -982,7 +982,7 @@ void* AllocChunk(cmsIT8* it8, cmsUInt32Number size)
cmsUInt32Number Free = it8 ->Allocator.BlockSize - it8 ->Allocator.Used;
cmsUInt8Number* ptr;
- size = _cmsALIGNLONG(size);
+ size = _cmsALIGNMEM(size);
if (size > Free) {
diff --git a/src/cmserr.c b/src/cmserr.c
index bfd2bd0..5f93c16 100644
--- a/src/cmserr.c
+++ b/src/cmserr.c
@@ -327,7 +327,7 @@ void* _cmsSubAlloc(_cmsSubAllocator* sub, cmsUInt32Number size)
cmsUInt32Number Free = sub -> h ->BlockSize - sub -> h -> Used;
cmsUInt8Number* ptr;
- size = _cmsALIGNLONG(size);
+ size = _cmsALIGNMEM(size);
// Check for memory. If there is no room, allocate a new chunk of double memory size.
if (size > Free) {
diff --git a/src/cmsplugin.c b/src/cmsplugin.c
index 1fa5ff4..36925aa 100644
--- a/src/cmsplugin.c
+++ b/src/cmsplugin.c
@@ -537,11 +537,11 @@ cmsBool CMSEXPORT cmsPlugin(void* Plug_in)
return FALSE;
}
- if (Plugin ->ExpectedVersion > LCMS_VERSION) {
- cmsSignalError(0, cmsERROR_UNKNOWN_EXTENSION, "plugin needs Little CMS %d, current version is %d",
- Plugin ->ExpectedVersion, LCMS_VERSION);
- return FALSE;
- }
+ if (Plugin ->ExpectedVersion > LCMS_VERSION) {
+ cmsSignalError(0, cmsERROR_UNKNOWN_EXTENSION, "plugin needs Little CMS %d, current version is %d",
+ Plugin ->ExpectedVersion, LCMS_VERSION);
+ return FALSE;
+ }
switch (Plugin -> Type) {
diff --git a/src/lcms2_internal.h b/src/lcms2_internal.h
index b40f301..39e38f0 100644
--- a/src/lcms2_internal.h
+++ b/src/lcms2_internal.h
@@ -54,8 +54,10 @@
// Alignment of ICC file format uses 4 bytes (cmsUInt32Number)
-#define _cmsSIZEOFLONGMINUS1 (sizeof(cmsUInt32Number)-1)
-#define _cmsALIGNLONG(x) (((x)+_cmsSIZEOFLONGMINUS1) & ~(_cmsSIZEOFLONGMINUS1))
+#define _cmsALIGNLONG(x) (((x)+(sizeof(cmsUInt32Number)-1)) & ~(sizeof(cmsUInt32Number)-1))
+
+// Alignment to memory pointer
+#define _cmsALIGNMEM(x) (((x)+(sizeof(void *) - 1)) & ~(sizeof(void *) - 1))
// Maximum encodeable values in floating point
#define MAX_ENCODEABLE_XYZ (1.0 + 32767.0/32768.0)
@@ -65,7 +67,7 @@
#define MAX_ENCODEABLE_ab4 (127.0)
// Maximum of channels for internal pipeline evaluation
-#define MAX_STAGE_CHANNELS 128
+#define MAX_STAGE_CHANNELS 128
// Unused parameter warning supression
#define cmsUNUSED_PARAMETER(x) ((void)x)