本文整理汇总了C++中LockSemaphoreInfo函数的典型用法代码示例。如果您正苦于以下问题:C++ LockSemaphoreInfo函数的具体用法?C++ LockSemaphoreInfo怎么用?C++ LockSemaphoreInfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LockSemaphoreInfo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetPolicyValue
static MagickBooleanType SetPolicyValue(const PolicyDomain domain,
const char *name,const char *value)
{
MagickBooleanType
status;
register PolicyInfo
*p;
status=MagickTrue;
LockSemaphoreInfo(policy_semaphore);
ResetLinkedListIterator(policy_cache);
p=(PolicyInfo *) GetNextValueInLinkedList(policy_cache);
while (p != (PolicyInfo *) NULL)
{
if ((p->domain == domain) && (LocaleCompare(name,p->name) == 0))
break;
p=(PolicyInfo *) GetNextValueInLinkedList(policy_cache);
}
if (p != (PolicyInfo *) NULL)
{
if (p->value != (char *) NULL)
p->value=DestroyString(p->value);
}
else
{
p=(PolicyInfo *) AcquireCriticalMemory(sizeof(*p));
(void) memset(p,0,sizeof(*p));
p->exempt=MagickFalse;
p->signature=MagickCoreSignature;
p->domain=domain;
p->name=ConstantString(name);
status=AppendValueToLinkedList(policy_cache,p);
}
p->value=ConstantString(value);
UnlockSemaphoreInfo(policy_semaphore);
if (status == MagickFalse)
p=(PolicyInfo *) RelinquishMagickMemory(p);
return(status);
}
示例2: InitializeLocaleList
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
+ I n i t i a l i z e L o c a l e L i s t %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% InitializeLocaleList() initializes the locale list.
%
% The format of the InitializeLocaleList method is:
%
% MagickBooleanType InitializeLocaleList(ExceptionInfo *exception)
%
% A description of each parameter follows.
%
% o exception: return any errors or warnings in this structure.
%
*/
static MagickBooleanType InitializeLocaleList(ExceptionInfo *exception)
{
if ((locale_list == (SplayTreeInfo *) NULL) &&
(instantiate_locale == MagickFalse))
{
if (locale_semaphore == (SemaphoreInfo *) NULL)
AcquireSemaphoreInfo(&locale_semaphore);
LockSemaphoreInfo(locale_semaphore);
if ((locale_list == (SplayTreeInfo *) NULL) &&
(instantiate_locale == MagickFalse))
{
char
*locale;
register const char
*p;
locale=(char *) NULL;
p=setlocale(LC_CTYPE,(const char *) NULL);
if (p != (const char *) NULL)
locale=ConstantString(p);
if (locale == (char *) NULL)
locale=GetEnvironmentValue("LC_ALL");
if (locale == (char *) NULL)
locale=GetEnvironmentValue("LC_MESSAGES");
if (locale == (char *) NULL)
locale=GetEnvironmentValue("LC_CTYPE");
if (locale == (char *) NULL)
locale=GetEnvironmentValue("LANG");
if (locale == (char *) NULL)
locale=ConstantString("C");
(void) LoadLocaleLists(LocaleFilename,locale,exception);
locale=DestroyString(locale);
instantiate_locale=MagickTrue;
}
UnlockSemaphoreInfo(locale_semaphore);
}
return(locale_list != (SplayTreeInfo *) NULL ? MagickTrue : MagickFalse);
}
示例3: DestroyMagickMemory
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
+ D e s t r o y M a g i c k M e m o r y %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DestroyMagickMemory() deallocates memory associated with the memory manager.
%
% The format of the DestroyMagickMemory method is:
%
% DestroyMagickMemory(void)
%
*/
MagickExport void DestroyMagickMemory(void)
{
#if defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
register ssize_t
i;
if (memory_semaphore == (SemaphoreInfo *) NULL)
ActivateSemaphoreInfo(&memory_semaphore);
LockSemaphoreInfo(memory_semaphore);
for (i=0; i < (ssize_t) memory_pool.number_segments; i++)
if (memory_pool.segments[i]->mapped == MagickFalse)
memory_methods.destroy_memory_handler(
memory_pool.segments[i]->allocation);
else
(void) UnmapBlob(memory_pool.segments[i]->allocation,
memory_pool.segments[i]->length);
free_segments=(DataSegmentInfo *) NULL;
(void) ResetMagickMemory(&memory_pool,0,sizeof(memory_pool));
UnlockSemaphoreInfo(memory_semaphore);
DestroySemaphoreInfo(&memory_semaphore);
#endif
}
示例4: AcquireSemaphoreInfo
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% A c q u i r e S e m a p h o r e I n f o %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% AcquireSemaphoreInfo() acquires a semaphore.
%
% The format of the AcquireSemaphoreInfo method is:
%
% void AcquireSemaphoreInfo(SemaphoreInfo **semaphore_info)
%
% A description of each parameter follows:
%
% o semaphore_info: Specifies a pointer to an SemaphoreInfo structure.
%
*/
MagickExport void AcquireSemaphoreInfo(SemaphoreInfo **semaphore_info)
{
assert(semaphore_info != (SemaphoreInfo **) NULL);
#if defined(MAGICKCORE_HAVE_PTHREAD)
if (pthread_mutex_lock(&semaphore_mutex) != 0)
(void) fprintf(stderr,"pthread_mutex_lock failed %s\n",
GetExceptionMessage(errno));
#elif defined(MAGICKORE_HAVE_WINTHREADS)
while (InterlockedCompareExchange(&semaphore_mutex,1L,0L) != 0)
Sleep(10);
#endif
if (*semaphore_info == (SemaphoreInfo *) NULL)
*semaphore_info=AllocateSemaphoreInfo();
#if defined(MAGICKCORE_HAVE_PTHREAD)
if (pthread_mutex_unlock(&semaphore_mutex) != 0)
(void) fprintf(stderr,"pthread_mutex_unlock failed %s\n",
GetExceptionMessage(errno));
#elif defined(MAGICKORE_HAVE_WINTHREADS)
InterlockedExchange(&semaphore_mutex,0L);
#endif
(void) LockSemaphoreInfo(*semaphore_info);
}
示例5: ListMagickResourceInfo
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% L i s t M a g i c k R e s o u r c e I n f o %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ListMagickResourceInfo() lists the resource info to a file.
%
% The format of the ListMagickResourceInfo method is:
%
% MagickBooleanType ListMagickResourceInfo(FILE *file,
% ExceptionInfo *exception)
%
% A description of each parameter follows.
%
% o file: An pointer to a FILE.
%
% o exception: return any errors or warnings in this structure.
%
*/
MagickExport MagickBooleanType ListMagickResourceInfo(FILE *file,
ExceptionInfo *magick_unused(exception))
{
char
area_limit[MaxTextExtent],
disk_limit[MaxTextExtent],
map_limit[MaxTextExtent],
memory_limit[MaxTextExtent],
time_limit[MaxTextExtent];
if (file == (const FILE *) NULL)
file=stdout;
if (resource_semaphore == (SemaphoreInfo *) NULL)
AcquireSemaphoreInfo(&resource_semaphore);
LockSemaphoreInfo(resource_semaphore);
(void) FormatMagickSize(resource_info.area_limit,MagickFalse,area_limit);
(void) FormatMagickSize(resource_info.memory_limit,MagickTrue,memory_limit);
(void) FormatMagickSize(resource_info.map_limit,MagickTrue,map_limit);
(void) CopyMagickString(disk_limit,"unlimited",MaxTextExtent);
if (resource_info.disk_limit != MagickResourceInfinity)
(void) FormatMagickSize(resource_info.disk_limit,MagickTrue,disk_limit);
(void) CopyMagickString(time_limit,"unlimited",MaxTextExtent);
if (resource_info.time_limit != MagickResourceInfinity)
(void) FormatLocaleString(time_limit,MaxTextExtent,"%.20g",(double)
((MagickOffsetType) resource_info.time_limit));
(void) FormatLocaleFile(file," File Area Memory Map"
" Disk Thread Throttle Time\n");
(void) FormatLocaleFile(file,
"--------------------------------------------------------"
"------------------------\n");
(void) FormatLocaleFile(file,"%6g %10s %10s %10s %10s %8g %8g %10s\n",
(double) ((MagickOffsetType) resource_info.file_limit),area_limit,
memory_limit,map_limit,disk_limit,(double) ((MagickOffsetType)
resource_info.thread_limit),(double) ((MagickOffsetType)
resource_info.throttle_limit),time_limit);
(void) fflush(file);
UnlockSemaphoreInfo(resource_semaphore);
return(MagickTrue);
}
示例6: ThrowException
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% T h r o w E x c e p t i o n %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ThrowException() throws an exception with the specified severity code,
% reason, and optional description.
%
% The format of the ThrowException method is:
%
% MagickBooleanType ThrowException(ExceptionInfo *exception,
% const ExceptionType severity,const char *reason,
% const char *description)
%
% A description of each parameter follows:
%
% o exception: the exception info.
%
% o severity: the severity of the exception.
%
% o reason: the reason for the exception.
%
% o description: the exception description.
%
*/
MagickExport MagickBooleanType ThrowException(ExceptionInfo *exception,
const ExceptionType severity,const char *reason,const char *description)
{
register ExceptionInfo
*p;
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
LockSemaphoreInfo(exception->semaphore);
p=(ExceptionInfo *) GetLastValueInLinkedList((LinkedListInfo *)
exception->exceptions);
if ((p != (ExceptionInfo *) NULL) && (p->severity == severity) &&
(LocaleCompare(exception->reason,reason) == 0) &&
(LocaleCompare(exception->description,description) == 0))
{
UnlockSemaphoreInfo(exception->semaphore);
return(MagickTrue);
}
p=(ExceptionInfo *) AcquireMagickMemory(sizeof(*p));
if (p == (ExceptionInfo *) NULL)
{
UnlockSemaphoreInfo(exception->semaphore);
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
}
(void) ResetMagickMemory(p,0,sizeof(*p));
p->severity=severity;
if (reason != (const char *) NULL)
p->reason=ConstantString(reason);
if (description != (const char *) NULL)
p->description=ConstantString(description);
p->signature=MagickSignature;
(void) AppendValueToLinkedList((LinkedListInfo *) exception->exceptions,p);
exception->severity=p->severity;
exception->reason=p->reason;
exception->description=p->description;
UnlockSemaphoreInfo(exception->semaphore);
return(MagickTrue);
}
示例7: GetMagicInfo
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
+ G e t M a g i c I n f o %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% GetMagicInfo() searches the magic list for the specified name and if found
% returns attributes for that magic.
%
% The format of the GetMagicInfo method is:
%
% const MagicInfo *GetMagicInfo(const unsigned char *magic,
% const size_t length,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o magic: A binary string generally representing the first few characters
% of the image file or blob.
%
% o length: the length of the binary signature.
%
% o exception: return any errors or warnings in this structure.
%
*/
MagickExport const MagicInfo *GetMagicInfo(const unsigned char *magic,
const size_t length,ExceptionInfo *exception)
{
register const MagicInfo
*p;
assert(exception != (ExceptionInfo *) NULL);
if ((magic_list == (LinkedListInfo *) NULL) ||
(instantiate_magic == MagickFalse))
if (InitializeMagicList(exception) == MagickFalse)
return((const MagicInfo *) NULL);
if ((magic_list == (LinkedListInfo *) NULL) ||
(IsLinkedListEmpty(magic_list) != MagickFalse))
return((const MagicInfo *) NULL);
if (magic == (const unsigned char *) NULL)
return((const MagicInfo *) GetValueFromLinkedList(magic_list,0));
if (length == 0)
return((const MagicInfo *) NULL);
/*
Search for magic tag.
*/
LockSemaphoreInfo(magic_semaphore);
ResetLinkedListIterator(magic_list);
p=(const MagicInfo *) GetNextValueInLinkedList(magic_list);
while (p != (const MagicInfo *) NULL)
{
assert(p->offset >= 0);
if (((size_t) (p->offset+p->length) <= length) &&
(memcmp(magic+p->offset,p->magic,p->length) == 0))
break;
p=(const MagicInfo *) GetNextValueInLinkedList(magic_list);
}
if (p != (const MagicInfo *) NULL)
(void) InsertValueInLinkedList(magic_list,0,
RemoveElementByValueFromLinkedList(magic_list,p));
UnlockSemaphoreInfo(magic_semaphore);
return(p);
}
示例8: DestroyExceptionInfo
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% D e s t r o y E x c e p t i o n I n f o %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DestroyExceptionInfo() deallocates memory associated with an exception.
%
% The format of the DestroyExceptionInfo method is:
%
% ExceptionInfo *DestroyExceptionInfo(ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o exception: the exception info.
%
*/
MagickExport ExceptionInfo *DestroyExceptionInfo(ExceptionInfo *exception)
{
MagickBooleanType
relinquish;
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
if (exception->semaphore == (SemaphoreInfo *) NULL)
AcquireSemaphoreInfo(&exception->semaphore);
LockSemaphoreInfo(exception->semaphore);
exception->severity=UndefinedException;
if (exception->exceptions != (void *) NULL)
exception->exceptions=(void *) DestroyLinkedList((LinkedListInfo *)
exception->exceptions,DestroyExceptionElement);
relinquish=exception->relinquish;
if (exception->relinquish != MagickFalse)
exception->signature=(~MagickSignature);
UnlockSemaphoreInfo(exception->semaphore);
DestroySemaphoreInfo(&exception->semaphore);
if (relinquish != MagickFalse)
exception=(ExceptionInfo *) RelinquishMagickMemory(exception);
return(exception);
}
示例9: LinkedListToArray
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% L i n k e d L i s t T o A r r a y %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% LinkedListToArray() converts the linked-list to an array.
%
% The format of the LinkedListToArray method is:
%
% MagickBooleanType LinkedListToArray(LinkedListInfo *list_info,
% void **array)
%
% A description of each parameter follows:
%
% o list_info: the linked-list info.
%
% o array: the array.
%
*/
MagickExport MagickBooleanType LinkedListToArray(LinkedListInfo *list_info,
void **array)
{
register ElementInfo
*next;
register ssize_t
i;
assert(list_info != (LinkedListInfo *) NULL);
assert(list_info->signature == MagickCoreSignature);
if (array == (void **) NULL)
return(MagickFalse);
LockSemaphoreInfo(list_info->semaphore);
next=list_info->head;
for (i=0; next != (ElementInfo *) NULL; i++)
{
array[i]=next->value;
next=next->next;
}
UnlockSemaphoreInfo(list_info->semaphore);
return(MagickTrue);
}
示例10: GetMagickInfo
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% G e t M a g i c k I n f o %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% GetMagickInfo() returns a pointer MagickInfo structure that matches
% the specified name. If name is NULL, the head of the image format list
% is returned. It is not safe to traverse the list by using the previous and
% next pointers in the MagickInfo structure since the list contents or order
% may be altered while the list is being traversed. If the list must be
% traversed, access it via the GetMagickInfoArray function instead.
%
% If GraphicsMagick has not been initialized via InitializeMagick()
% then this function will not work.
%
% The format of the GetMagickInfo method is:
%
% const MagickInfo *GetMagickInfo(const char *name,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o name: The image format we are looking for.
%
% o exception: Return any errors or warnings in this structure.
%
%
*/
static MagickInfo *
GetMagickInfoEntryLocked(const char *name)
{
register MagickInfo
*p;
LockSemaphoreInfo(magick_semaphore);
p=magick_list;
if ((name != (const char *) NULL) && (name[0] != '*'))
{
for (p=magick_list; p != (MagickInfo *) NULL; p=p->next)
if (LocaleCompare(p->name,name) == 0)
break;
if (p != (MagickInfo *) NULL)
if (p != magick_list)
{
/*
Self-adjusting list.
*/
if (p->previous != (MagickInfo *) NULL)
p->previous->next=p->next;
if (p->next != (MagickInfo *) NULL)
p->next->previous=p->previous;
p->previous=(MagickInfo *) NULL;
p->next=magick_list;
magick_list->previous=p;
magick_list=p;
}
}
UnlockSemaphoreInfo(magick_semaphore);
return p;
}
示例11: ClearMagickException
MagickExport void ClearMagickException(ExceptionInfo *exception)
{
register ExceptionInfo
*p;
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
if (exception->exceptions == (void *) NULL)
return;
LockSemaphoreInfo(exception->semaphore);
p=(ExceptionInfo *) RemoveLastElementFromLinkedList((LinkedListInfo *)
exception->exceptions);
while (p != (ExceptionInfo *) NULL)
{
(void) DestroyExceptionElement(p);
p=(ExceptionInfo *) RemoveLastElementFromLinkedList((LinkedListInfo *)
exception->exceptions);
}
exception->severity=UndefinedException;
exception->reason=(char *) NULL;
exception->description=(char *) NULL;
UnlockSemaphoreInfo(exception->semaphore);
errno=0;
}
示例12: HasError
int HasError(ExceptionInfo *exception) {
register const ExceptionInfo *p;
int result = 0;
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
if (exception->exceptions == (void *) NULL)
return 0;
if (exception->semaphore == (void *) NULL)
return 0;
LockSemaphoreInfo(exception->semaphore);
ResetLinkedListIterator((LinkedListInfo *) exception->exceptions);
p=(const ExceptionInfo *) GetNextValueInLinkedList((LinkedListInfo *)
exception->exceptions);
while (p != (const ExceptionInfo *) NULL) {
if (p->severity >= ErrorException)
result = 1;
p=(const ExceptionInfo *) GetNextValueInLinkedList((LinkedListInfo *)
exception->exceptions);
}
UnlockSemaphoreInfo(exception->semaphore);
return result;
}
示例13: InheritException
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% I n h e r i t E x c e p t i o n %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% InheritException() inherits an exception from a related exception.
%
% The format of the InheritException method is:
%
% InheritException(ExceptionInfo *exception,const ExceptionInfo *relative)
%
% A description of each parameter follows:
%
% o exception: the exception info.
%
% o relative: the related exception info.
%
*/
MagickExport void InheritException(ExceptionInfo *exception,
const ExceptionInfo *relative)
{
register const ExceptionInfo
*p;
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
assert(relative != (ExceptionInfo *) NULL);
assert(relative->signature == MagickSignature);
if (relative->exceptions == (void *) NULL)
return;
LockSemaphoreInfo(relative->semaphore);
ResetLinkedListIterator((LinkedListInfo *) relative->exceptions);
p=(const ExceptionInfo *) GetNextValueInLinkedList((LinkedListInfo *)
relative->exceptions);
while (p != (const ExceptionInfo *) NULL)
{
(void) ThrowException(exception,p->severity,p->reason,p->description);
p=(const ExceptionInfo *) GetNextValueInLinkedList((LinkedListInfo *)
relative->exceptions);
}
UnlockSemaphoreInfo(relative->semaphore);
}
示例14: GetValueFromLinkedList
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% G e t V a l u e F r o m L i n k e d L i s t %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% GetValueFromLinkedList() gets a value from the linked-list at the specified
% location.
%
% The format of the GetValueFromLinkedList method is:
%
% void *GetValueFromLinkedList(LinkedListInfo *list_info,
% const size_t index)
%
% A description of each parameter follows:
%
% o list_info: the linked_list info.
%
% o index: the list index.
%
*/
MagickExport void *GetValueFromLinkedList(LinkedListInfo *list_info,
const size_t index)
{
register ElementInfo
*next;
register ssize_t
i;
void
*value;
assert(list_info != (LinkedListInfo *) NULL);
assert(list_info->signature == MagickCoreSignature);
if (index >= list_info->elements)
return((void *) NULL);
LockSemaphoreInfo(list_info->semaphore);
if (index == 0)
{
value=list_info->head->value;
UnlockSemaphoreInfo(list_info->semaphore);
return(value);
}
if (index == (list_info->elements-1))
{
value=list_info->tail->value;
UnlockSemaphoreInfo(list_info->semaphore);
return(value);
}
next=list_info->head;
for (i=0; i < (ssize_t) index; i++)
next=next->next;
value=next->value;
UnlockSemaphoreInfo(list_info->semaphore);
return(value);
}
示例15: RelinquishUniqueFileResource
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% R e l i n q u i s h U n i q u e F i l e R e s o u r c e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% RelinquishUniqueFileResource() relinquishes a unique file resource.
%
% The format of the RelinquishUniqueFileResource() method is:
%
% MagickBooleanType RelinquishUniqueFileResource(const char *path)
%
% A description of each parameter follows:
%
% o name: the name of the temporary resource.
%
*/
MagickExport MagickBooleanType RelinquishUniqueFileResource(const char *path)
{
char
cache_path[MagickPathExtent];
MagickBooleanType
status;
assert(path != (const char *) NULL);
status=MagickFalse;
(void) LogMagickEvent(ResourceEvent,GetMagickModule(),"%s",path);
if (resource_semaphore == (SemaphoreInfo *) NULL)
ActivateSemaphoreInfo(&resource_semaphore);
LockSemaphoreInfo(resource_semaphore);
if (temporary_resources != (SplayTreeInfo *) NULL)
status=DeleteNodeFromSplayTree(temporary_resources, (const void *) path);
UnlockSemaphoreInfo(resource_semaphore);
(void) CopyMagickString(cache_path,path,MagickPathExtent);
AppendImageFormat("cache",cache_path);
(void) ShredFile(cache_path);
if (status == MagickFalse)
status=ShredFile(path);
return(status);
}