From b5c339c1527acc6d14ca86055e4a4081cc4fb00e Mon Sep 17 00:00:00 2001 From: Marti Maria Date: Wed, 2 Nov 2011 12:18:23 +0100 Subject: Memory alignment macro for CGATS parser --- AUTHORS | 1 + ChangeLog | 2 +- src/cmscgats.c | 4 ++-- src/cmserr.c | 2 +- src/cmsplugin.c | 10 +++++----- src/lcms2_internal.h | 8 +++++--- 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) -- cgit v1.2.1