| 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % W W AAA N N DDDD % |
| 7 | % W W A A NN N D D % |
| 8 | % W W W AAAAA N N N D D % |
| 9 | % WW WW A A N NN D D % |
| 10 | % W W A A N N DDDD % |
| 11 | % % |
| 12 | % % |
| 13 | % MagickWand Support Methods % |
| 14 | % % |
| 15 | % Software Design % |
| 16 | % Cristy % |
| 17 | % May 2004 % |
| 18 | % % |
| 19 | % % |
| 20 | % Copyright @ 1999 ImageMagick Studio LLC, a non-profit organization % |
| 21 | % dedicated to making software imaging solutions freely available. % |
| 22 | % % |
| 23 | % You may not use this file except in compliance with the License. You may % |
| 24 | % obtain a copy of the License at % |
| 25 | % % |
| 26 | % https://imagemagick.org/license/ % |
| 27 | % % |
| 28 | % Unless required by applicable law or agreed to in writing, software % |
| 29 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 30 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 31 | % See the License for the specific language governing permissions and % |
| 32 | % limitations under the License. % |
| 33 | % % |
| 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 35 | % |
| 36 | % Assign unique ID's to each magick wand. We store the ID's in a splay-tree |
| 37 | % to track which ID's persist and which were destroyed. |
| 38 | % |
| 39 | % |
| 40 | */ |
| 41 | |
| 42 | /* |
| 43 | Include declarations. |
| 44 | */ |
| 45 | #include "MagickWand/studio.h"cxx . . $ `<file>/MagickWand/studio.h`/ |
| 46 | #include "MagickWand/MagickWand.h"cxx . . $ `<file>/MagickWand/MagickWand.h`/ |
| 47 | #include "MagickWand/magick-wand-private.h"cxx . . $ `<file>/MagickWand/magick-wand-private.h`/ |
| 48 | #include "MagickWand/wand.h"cxx . . $ `<file>/MagickWand/wand.h`/ |
| 49 | |
| 50 | static SplayTreeInfocxx . . $ SplayTreeInfo# |
| 51 | *wand_idscxx . . $ wand_ids. = (SplayTreeInfocxx . . $ SplayTreeInfo# *) NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 52 | |
| 53 | static MagickBooleanTypecxx . . $ MagickBooleanType# |
| 54 | instantiate_wandcxx . . $ instantiate_wand. = MagickFalsecxx . . $ MagickFalse.; |
| 55 | |
| 56 | static SemaphoreInfocxx . . $ SemaphoreInfo# |
| 57 | *wand_semaphorecxx . . $ wand_semaphore. = (SemaphoreInfocxx . . $ SemaphoreInfo# *) NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 58 | |
| 59 | /* |
| 60 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 61 | % % |
| 62 | % % |
| 63 | % % |
| 64 | % A c q u i r e W a n d I d % |
| 65 | % % |
| 66 | % % |
| 67 | % % |
| 68 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 69 | % |
| 70 | % AcquireWandId() returns a unique wand id. |
| 71 | % |
| 72 | % The format of the AcquireWandId() method is: |
| 73 | % |
| 74 | % size_t AcquireWandId() |
| 75 | % |
| 76 | */ |
| 77 | WandExportcxx . . $ `MagickWand/method-attribute.h:58:13`! size_t AcquireWandIdcxx . . $ AcquireWandId(f708dce9a8856c70).(void) |
| 78 | { |
| 79 | MagickAddressTypecxx . . $ MagickAddressType# |
| 80 | wand_id; |
| 81 | |
| 82 | static size_t |
| 83 | id = 0; |
| 84 | |
| 85 | if (wand_semaphorecxx . . $ wand_semaphore. == (SemaphoreInfocxx . . $ SemaphoreInfo# *) NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 86 | ActivateSemaphoreInfocxx . . $ ActivateSemaphoreInfo(61c9df362ed5e9e3).(&wand_semaphorecxx . . $ wand_semaphore.); |
| 87 | LockSemaphoreInfocxx . . $ LockSemaphoreInfo(7cc9bb5c0a5f683e).(wand_semaphorecxx . . $ wand_semaphore.); |
| 88 | if (wand_idscxx . . $ wand_ids. == (SplayTreeInfocxx . . $ SplayTreeInfo# *) NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 89 | wand_idscxx . . $ wand_ids.=NewSplayTreecxx . . $ NewSplayTree(de7be4758ee41708).((int (*)(const void *,const void *)) NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, |
| 90 | (void *(*)(void *)) NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,(void *(*)(void *)) NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 91 | wand_id=id++; |
| 92 | (void) AddValueToSplayTreecxx . . $ AddValueToSplayTree(fe81302f0985d85c).(wand_idscxx . . $ wand_ids.,(const void *) wand_id,(const void *) |
| 93 | wand_id); |
| 94 | instantiate_wandcxx . . $ instantiate_wand.=MagickTruecxx . . $ MagickTrue.; |
| 95 | UnlockSemaphoreInfocxx . . $ UnlockSemaphoreInfo(7cc9bb5c0a5f683e).(wand_semaphorecxx . . $ wand_semaphore.); |
| 96 | return((size_t) wand_id); |
| 97 | } |
| 98 | |
| 99 | /* |
| 100 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 101 | % % |
| 102 | % % |
| 103 | % % |
| 104 | % D e s t r o y W a n d I d s % |
| 105 | % % |
| 106 | % % |
| 107 | % % |
| 108 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 109 | % |
| 110 | % DestroyWandIds() deallocates memory associated with the wand id's. |
| 111 | % |
| 112 | % The format of the DestroyWandIds() method is: |
| 113 | % |
| 114 | % void DestroyWandIds(void) |
| 115 | % |
| 116 | % A description of each parameter follows: |
| 117 | % |
| 118 | */ |
| 119 | WandExportcxx . . $ `MagickWand/method-attribute.h:58:13`! void DestroyWandIdscxx . . $ DestroyWandIds(49f6e7a06ebc5aa8).(void) |
| 120 | { |
| 121 | if (wand_semaphorecxx . . $ wand_semaphore. == (SemaphoreInfocxx . . $ SemaphoreInfo# *) NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 122 | ActivateSemaphoreInfocxx . . $ ActivateSemaphoreInfo(61c9df362ed5e9e3).(&wand_semaphorecxx . . $ wand_semaphore.); |
| 123 | LockSemaphoreInfocxx . . $ LockSemaphoreInfo(7cc9bb5c0a5f683e).(wand_semaphorecxx . . $ wand_semaphore.); |
| 124 | if (wand_idscxx . . $ wand_ids. != (SplayTreeInfocxx . . $ SplayTreeInfo# *) NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 125 | wand_idscxx . . $ wand_ids.=DestroySplayTreecxx . . $ DestroySplayTree(8dad3d1d0a52a0e4).(wand_idscxx . . $ wand_ids.); |
| 126 | instantiate_wandcxx . . $ instantiate_wand.=MagickFalsecxx . . $ MagickFalse.; |
| 127 | UnlockSemaphoreInfocxx . . $ UnlockSemaphoreInfo(7cc9bb5c0a5f683e).(wand_semaphorecxx . . $ wand_semaphore.); |
| 128 | RelinquishSemaphoreInfocxx . . $ RelinquishSemaphoreInfo(61c9df362ed5e9e3).(&wand_semaphorecxx . . $ wand_semaphore.); |
| 129 | } |
| 130 | |
| 131 | /* |
| 132 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 133 | % % |
| 134 | % % |
| 135 | % % |
| 136 | % R e l i n q u i s h W a n d I d % |
| 137 | % % |
| 138 | % % |
| 139 | % % |
| 140 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 141 | % |
| 142 | % RelinquishWandId() relinquishes a unique wand id. |
| 143 | % |
| 144 | % The format of the RelinquishWandId() method is: |
| 145 | % |
| 146 | % void RelinquishWandId(const size_t *id) |
| 147 | % |
| 148 | % A description of each parameter follows: |
| 149 | % |
| 150 | % o id: a unique wand id. |
| 151 | % |
| 152 | */ |
| 153 | WandExportcxx . . $ `MagickWand/method-attribute.h:58:13`! void RelinquishWandIdcxx . . $ RelinquishWandId(2c44cd906ae4e829).(const size_t id) |
| 154 | { |
| 155 | MagickAddressTypecxx . . $ MagickAddressType# |
| 156 | wand_id = (MagickAddressTypecxx . . $ MagickAddressType#) id; |
| 157 | |
| 158 | LockSemaphoreInfocxx . . $ LockSemaphoreInfo(7cc9bb5c0a5f683e).(wand_semaphorecxx . . $ wand_semaphore.); |
| 159 | if (wand_idscxx . . $ wand_ids. != (SplayTreeInfocxx . . $ SplayTreeInfo# *) NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 160 | (void) DeleteNodeFromSplayTreecxx . . $ DeleteNodeFromSplayTree(1c4e53f703b2c29b).(wand_idscxx . . $ wand_ids.,(const void *) wand_id); |
| 161 | UnlockSemaphoreInfocxx . . $ UnlockSemaphoreInfo(7cc9bb5c0a5f683e).(wand_semaphorecxx . . $ wand_semaphore.); |
| 162 | } |