From: cristy Date: Sun, 30 Mar 2014 23:17:57 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~2525 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cba9e959d0f29270805bfadaf77aa0a42b635511;p=imagemagick --- diff --git a/MagickCore/matrix.c b/MagickCore/matrix.c index 53ce0ca46..5efe945ed 100644 --- a/MagickCore/matrix.c +++ b/MagickCore/matrix.c @@ -49,6 +49,7 @@ #include "MagickCore/memory_.h" #include "MagickCore/pixel-private.h" #include "MagickCore/resource_.h" +#include "MagickCore/semaphore.h" #include "MagickCore/utility.h" /* @@ -80,6 +81,9 @@ struct _MatrixInfo void *elements; + SemaphoreInfo + *semaphore; + size_t signature; }; @@ -217,6 +221,7 @@ MagickExport MatrixInfo *AcquireMatrixInfo(const size_t columns, matrix_info->columns=columns; matrix_info->rows=rows; matrix_info->stride=stride; + matrix_info->semaphore=AcquireSemaphoreInfo(); synchronize=GetEnvironmentValue("MAGICK_SYNCHRONIZE"); if (synchronize != (const char *) NULL) { @@ -372,6 +377,7 @@ MagickExport MatrixInfo *DestroyMatrixInfo(MatrixInfo *matrix_info) { assert(matrix_info != (MatrixInfo *) NULL); assert(matrix_info->signature == MagickSignature); + LockSemaphoreInfo(matrix_info->semaphore); switch (matrix_info->type) { case MemoryCache: @@ -403,6 +409,8 @@ MagickExport MatrixInfo *DestroyMatrixInfo(MatrixInfo *matrix_info) default: break; } + UnlockSemaphoreInfo(matrix_info->semaphore); + RelinquishSemaphoreInfo(&matrix_info->semaphore); return((MatrixInfo *) RelinquishMagickMemory(matrix_info)); } @@ -712,8 +720,10 @@ MagickExport MagickBooleanType GetMatrixElement(const MatrixInfo *matrix_info, matrix_info->stride,matrix_info->stride); return(MagickTrue); } + LockSemaphoreInfo(matrix_info->semaphore); count=ReadMatrixElements(matrix_info,i*matrix_info->stride, matrix_info->stride,value); + UnlockSemaphoreInfo(matrix_info->semaphore); if (count != (MagickOffsetType) matrix_info->stride) return(MagickFalse); return(MagickTrue); @@ -985,8 +995,10 @@ MagickExport MagickBooleanType SetMatrixElement(const MatrixInfo *matrix_info, matrix_info->stride,value,matrix_info->stride); return(MagickTrue); } + LockSemaphoreInfo(matrix_info->semaphore); count=WriteMatrixElements(matrix_info,i*matrix_info->stride, matrix_info->stride,value); + UnlockSemaphoreInfo(matrix_info->semaphore); if (count != (MagickOffsetType) matrix_info->stride) return(MagickFalse); return(MagickTrue);