Thanks for the reply. I totally had to do the nill check where you pointed
out. But that does not solve the problem either.
Here's the new code:

extern "C" __declspec(dllexport) int ToneMapping(int* intPtr, int size,
char* icc1, int len_icc1, char* icc2, int len_icc2)
{
char* icc_1 = NULL;
char* icc_2 = NULL;
icc_1 = (char*)malloc(sizeof(char)*len_icc1 +1);
icc_2 = (char*)malloc(sizeof(char)*len_icc2 +1);
if(icc_1 == NULL || icc_2 == NULL) return -1;

memcpy(icc_1, icc1, len_icc1);
memcpy(icc_2, icc2, len_icc2);
 cmsHPROFILE hInProfile = NULL;
cmsHPROFILE  hOutProfile = NULL;
cmsHTRANSFORM hTransform = NULL;
hInProfile = cmsOpenProfileFromFile(icc_2, "r");
hOutProfile = cmsOpenProfileFromFile(icc_1, "r");
if(hInProfile == NULL || hOutProfile == NULL) return -2;

hTransform = cmsCreateTransform(hInProfile,
TYPE_BGR_8,
hOutProfile,
TYPE_BGR_8,
INTENT_PERCEPTUAL, 0);

if(hTransform == NULL) return -3;
cmsDoTransform(hTransform, intPtr,
intPtr,
size);
 free(icc_1);
free(icc_2);
free(hInProfile);
free(hOutProfile);
free(hTransform);
return 1;
}

it's first call returns 1 which means it works fine. But the next calls
return -2 which means "cmsOpenProfileFromFile" gives NULL. Do you know why
it happens?

On Fri, Feb 22, 2013 at 12:56 PM, Christian Schmitz <
realbasicli...@monkeybreadsoftware.de> wrote:

>
> On 22.02.2013, at 21:36, Devon Yoo <9tontr...@gmail.com> wrote:
>
> >       char* icc_1 = (char*)malloc(sizeof(char)*len_icc1 +1);
> >       char* icc_2 = (char*)malloc(sizeof(char)*len_icc2 +1);
>
> nil checks after malloc?
>
> >       hInProfile = cmsOpenProfileFromFile(icc_2, "r");
> >       hOutProfile = cmsOpenProfileFromFile(icc_1, "r");
>
> nil checks after opening profile?
>
> >       hTransform = cmsCreateTransform(hInProfile,
> >
> TYPE_BGR_8,
> >
> hOutProfile,
> >
> TYPE_BGR_8,
> >
> INTENT_PERCEPTUAL, 0);
>
> Nil check after transform?
>
> >       free(icc_1);
> >       free(icc_2);
>
> You need to verify that results are valid!
>
> Greetings
> Christian
>
> --
> Read our blog about news on our plugins:
>
> http://www.mbsplugins.de/
>
>
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Lcms-user mailing list
Lcms-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lcms-user

Reply via email to