00001 /* 00002 Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization 00003 dedicated to making software imaging solutions freely available. 00004 00005 You may not use this file except in compliance with the License. 00006 obtain a copy of the License at 00007 00008 http://www.imagemagick.org/script/license.php 00009 00010 Unless required by applicable law or agreed to in writing, software 00011 distributed under the License is distributed on an "AS IS" BASIS, 00012 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 See the License for the specific language governing permissions and 00014 limitations under the License. 00015 00016 MagickCore random generation private methods. 00017 */ 00018 #ifndef _MAGICKCORE_RANDOM_PRIVATE_H 00019 #define _MAGICKCORE_RANDOM_PRIVATE_H 00020 00021 #if defined(__cplusplus) || defined(c_plusplus) 00022 extern "C" { 00023 #endif 00024 00025 #include "magick/thread-private.h" 00026 00027 static inline RandomInfo **DestroyRandomInfoThreadSet( 00028 RandomInfo **random_info) 00029 { 00030 register long 00031 i; 00032 00033 assert(random_info != (RandomInfo **) NULL); 00034 for (i=0; i < (long) GetOpenMPMaximumThreads(); i++) 00035 if (random_info[i] != (RandomInfo *) NULL) 00036 random_info[i]=DestroyRandomInfo(random_info[i]); 00037 return((RandomInfo **) RelinquishAlignedMemory(random_info)); 00038 } 00039 00040 static inline RandomInfo **AcquireRandomInfoThreadSet(void) 00041 { 00042 register long 00043 i; 00044 00045 RandomInfo 00046 **random_info; 00047 00048 unsigned long 00049 number_threads; 00050 00051 number_threads=GetOpenMPMaximumThreads(); 00052 random_info=(RandomInfo **) AcquireAlignedMemory(number_threads, 00053 sizeof(*random_info)); 00054 if (random_info == (RandomInfo **) NULL) 00055 return((RandomInfo **) NULL); 00056 (void) ResetMagickMemory(random_info,0,number_threads*sizeof(*random_info)); 00057 for (i=0; i < (long) number_threads; i++) 00058 { 00059 random_info[i]=AcquireRandomInfo(); 00060 if (random_info[i] == (RandomInfo *) NULL) 00061 return(DestroyRandomInfoThreadSet(random_info)); 00062 } 00063 return(random_info); 00064 } 00065 00066 #if defined(__cplusplus) || defined(c_plusplus) 00067 } 00068 #endif 00069 00070 #endif
1.6.1