MagickCore  7.0.7
Convert, Edit, Or Compose Bitmap Images
random-private.h
Go to the documentation of this file.
1 /*
2  Copyright 1999-2018 ImageMagick Studio LLC, a non-profit organization
3  dedicated to making software imaging solutions freely available.
4 
5  You may not use this file except in compliance with the License.
6  obtain a copy of the License at
7 
8  https://www.imagemagick.org/script/license.php
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16  MagickCore random generation private methods.
17 */
18 #ifndef MAGICKCORE_RANDOM_PRIVATE_H
19 #define MAGICKCORE_RANDOM_PRIVATE_H
20 
22 
23 #if defined(__cplusplus) || defined(c_plusplus)
24 extern "C" {
25 #endif
26 
27 extern MagickPrivate double
29 
32 
33 extern MagickPrivate unsigned long
35 
36 extern MagickPrivate void
38 
41 {
42  register ssize_t
43  i;
44 
45  assert(random_info != (RandomInfo **) NULL);
46  for (i=0; i < (ssize_t) GetMagickResourceLimit(ThreadResource); i++)
47  if (random_info[i] != (RandomInfo *) NULL)
48  random_info[i]=DestroyRandomInfo(random_info[i]);
49  return((RandomInfo **) RelinquishMagickMemory(random_info));
50 }
51 
53 {
54  register ssize_t
55  i;
56 
58  **random_info;
59 
60  size_t
62 
63  number_threads=(size_t) GetMagickResourceLimit(ThreadResource);
64  random_info=(RandomInfo **) AcquireQuantumMemory(number_threads,
65  sizeof(*random_info));
66  if (random_info == (RandomInfo **) NULL)
67  ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
68  (void) ResetMagickMemory(random_info,0,number_threads*sizeof(*random_info));
69  for (i=0; i < (ssize_t) number_threads; i++)
70  random_info[i]=AcquireRandomInfo();
71  return(random_info);
72 }
73 
74 #if defined(__cplusplus) || defined(c_plusplus)
75 }
76 #endif
77 
78 #endif
MagickPrivate void RandomComponentTerminus(void)
Definition: random.c:825
#define ThrowFatalException(severity, tag)
static RandomInfo ** DestroyRandomInfoThreadSet(RandomInfo **random_info)
static RandomInfo ** AcquireRandomInfoThreadSet(void)
MagickPrivate double GetRandomInfoNormalize(const RandomInfo *)
Definition: random.c:652
MagickExport RandomInfo * DestroyRandomInfo(RandomInfo *random_info)
Definition: random.c:274
MagickBooleanType
Definition: magick-type.h:156
MagickPrivate MagickBooleanType RandomComponentGenesis(void)
Definition: random.c:800
MagickExport void * ResetMagickMemory(void *memory, int byte, const size_t size)
Definition: memory.c:1164
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
Definition: memory.c:529
MagickExport RandomInfo * AcquireRandomInfo(void)
Definition: random.c:164
MagickExport MagickSizeType GetMagickResourceLimit(const ResourceType type)
Definition: resource.c:758
size_t number_threads
MagickPrivate unsigned long * GetRandomInfoSeed(RandomInfo *)
Definition: random.c:680
static RandomInfo * random_info
Definition: resource.c:109
MagickExport void * RelinquishMagickMemory(void *memory)
Definition: memory.c:1038
#define MagickPrivate