]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Sun, 30 Mar 2014 23:17:57 +0000 (23:17 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sun, 30 Mar 2014 23:17:57 +0000 (23:17 +0000)
MagickCore/matrix.c

index 53ce0ca466c58f09433af106a902c1d9ca4fc622..5efe945ed627d3be7c8362321906eeb0f5953b3e 100644 (file)
@@ -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"
 \f
 /*
@@ -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));
 }
 \f
@@ -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);