MagickCore  7.0.1
memory.c File Reference
Include dependency graph for memory.c:

Go to the source code of this file.

Data Structures

struct  _DataSegmentInfo
 
struct  _MagickMemoryMethods
 
struct  _MemoryInfo
 
struct  _MemoryPool
 

Macros

#define BlockFooter(block, size)   ((size_t *) ((char *) (block)+(size)-2*sizeof(size_t)))
 
#define BlockHeader(block)   ((size_t *) (block)-1)
 
#define BlockSize   4096
 
#define BlockThreshold   1024
 
#define MaxBlockExponent   16
 
#define MaxBlocks   ((BlockThreshold/(4*sizeof(size_t)))+MaxBlockExponent+1)
 
#define MaxSegments   1024
 
#define MemoryGuard   ((0xdeadbeef << 31)+0xdeafdeed)
 
#define NextBlock(block)   ((char *) (block)+SizeOfBlock(block))
 
#define NextBlockInList(block)   (*(void **) (block))
 
#define PreviousBlock(block)   ((char *) (block)-(*((size_t *) (block)-2)))
 
#define PreviousBlockBit   0x01
 
#define PreviousBlockInList(block)   (*((void **) (block)+1))
 
#define SegmentSize   (2*1024*1024)
 
#define SizeMask   (~0x01)
 
#define SizeOfBlock(block)   (*BlockHeader(block) & SizeMask)
 
#define AlignedExtent(size, alignment)   (((size)+((alignment)-1)) & ~((alignment)-1))
 

Typedefs

typedef struct _DataSegmentInfo DataSegmentInfo
 
typedef struct _MagickMemoryMethods MagickMemoryMethods
 
typedef struct _MemoryPool MemoryPool
 

Enumerations

enum  VirtualMemoryType { UndefinedVirtualMemory, AlignedVirtualMemory, MapVirtualMemory, UnalignedVirtualMemory }
 

Functions

static MagickBooleanType CheckMemoryOverflow (const size_t count, const size_t quantum)
 
MagickExport void * AcquireAlignedMemory (const size_t count, const size_t quantum)
 
MagickExport void * AcquireMagickMemory (const size_t size)
 
MagickExport void * AcquireQuantumMemory (const size_t count, const size_t quantum)
 
MagickExport MemoryInfoAcquireVirtualMemory (const size_t count, const size_t quantum)
 
MagickExport void * CopyMagickMemory (void *destination, const void *source, const size_t size)
 
MagickExport void DestroyMagickMemory (void)
 
MagickExport void GetMagickMemoryMethods (AcquireMemoryHandler *acquire_memory_handler, ResizeMemoryHandler *resize_memory_handler, DestroyMemoryHandler *destroy_memory_handler)
 
MagickExport void * GetVirtualMemoryBlob (const MemoryInfo *memory_info)
 
MagickExport void * RelinquishAlignedMemory (void *memory)
 
MagickExport void * RelinquishMagickMemory (void *memory)
 
MagickExport MemoryInfoRelinquishVirtualMemory (MemoryInfo *memory_info)
 
MagickExport void * ResetMagickMemory (void *memory, int byte, const size_t size)
 
MagickExport void * ResizeMagickMemory (void *memory, const size_t size)
 
MagickExport void * ResizeQuantumMemory (void *memory, const size_t count, const size_t quantum)
 
MagickExport void SetMagickMemoryMethods (AcquireMemoryHandler acquire_memory_handler, ResizeMemoryHandler resize_memory_handler, DestroyMemoryHandler destroy_memory_handler)
 

Variables

static MagickMemoryMethods memory_methods
 

Macro Definition Documentation

#define AlignedExtent (   size,
  alignment 
)    (((size)+((alignment)-1)) & ~((alignment)-1))

Referenced by AcquireAlignedMemory().

#define BlockFooter (   block,
  size 
)    ((size_t *) ((char *) (block)+(size)-2*sizeof(size_t)))

Definition at line 71 of file memory.c.

Referenced by RelinquishMagickMemory().

#define BlockHeader (   block)    ((size_t *) (block)-1)

Definition at line 73 of file memory.c.

Referenced by RelinquishMagickMemory().

#define BlockSize   4096

Definition at line 74 of file memory.c.

#define BlockThreshold   1024

Definition at line 75 of file memory.c.

#define MaxBlockExponent   16

Definition at line 76 of file memory.c.

#define MaxBlocks   ((BlockThreshold/(4*sizeof(size_t)))+MaxBlockExponent+1)

Definition at line 77 of file memory.c.

Referenced by AcquireMagickMemory().

#define MaxSegments   1024

Definition at line 78 of file memory.c.

Referenced by AcquireMagickMemory().

#define MemoryGuard   ((0xdeadbeef << 31)+0xdeafdeed)

Definition at line 79 of file memory.c.

#define NextBlock (   block)    ((char *) (block)+SizeOfBlock(block))

Definition at line 80 of file memory.c.

Referenced by RelinquishMagickMemory().

#define NextBlockInList (   block)    (*(void **) (block))

Definition at line 81 of file memory.c.

#define PreviousBlock (   block)    ((char *) (block)-(*((size_t *) (block)-2)))

Definition at line 82 of file memory.c.

Referenced by RelinquishMagickMemory().

#define PreviousBlockBit   0x01

Definition at line 83 of file memory.c.

Referenced by RelinquishMagickMemory().

#define PreviousBlockInList (   block)    (*((void **) (block)+1))

Definition at line 84 of file memory.c.

#define SegmentSize   (2*1024*1024)

Definition at line 85 of file memory.c.

Referenced by AcquireMagickMemory().

#define SizeMask   (~0x01)

Definition at line 86 of file memory.c.

Referenced by AcquireMagickMemory(), and RelinquishMagickMemory().

#define SizeOfBlock (   block)    (*BlockHeader(block) & SizeMask)

Definition at line 87 of file memory.c.

Referenced by RelinquishMagickMemory().

Typedef Documentation

typedef struct _MemoryPool MemoryPool

Enumeration Type Documentation

Enumerator
UndefinedVirtualMemory 
AlignedVirtualMemory 
MapVirtualMemory 
UnalignedVirtualMemory 

Definition at line 92 of file memory.c.

Function Documentation

MagickExport void* AcquireMagickMemory ( const size_t  size)

Definition at line 470 of file memory.c.

References _MagickMemoryMethods::acquire_memory_handler, ActivateSemaphoreInfo(), _MemoryPool::allocation, _MemoryPool::blocks, LockSemaphoreInfo(), MagickFalse, MaxBlocks, MaxSegments, memory_methods, _DataSegmentInfo::next, _DataSegmentInfo::previous, ResetMagickMemory(), _MemoryPool::segment_pool, SegmentSize, SizeMask, and UnlockSemaphoreInfo().

Referenced by AcquireCoderCache(), AcquireColorCache(), AcquireConfigureCache(), AcquireDistributeCacheInfo(), AcquireDrawInfo(), AcquireExceptionInfo(), AcquireFxInfo(), AcquireImage(), AcquireImageInfo(), AcquireKernelBuiltIn(), AcquireLogCache(), AcquireMagicCache(), AcquireMagickInfo(), AcquireMatrixInfo(), AcquirePixelList(), AcquirePolicyCache(), AcquireQuantizeInfo(), AcquireQuantumInfo(), AcquireQuantumMemory(), AcquireRandomInfo(), AcquireResampleFilter(), AcquireResizeFilter(), AcquireSignatureInfo(), AcquireStreamInfo(), AcquireStringInfo(), AcquireTimerInfo(), AcquireTokenInfo(), AcquireVirtualMemory(), AddChildToXMLTree(), AddValueToSplayTree(), AppendValueToLinkedList(), Ascii85Initialize(), CheckImageColors(), Classify(), ClassifyImageColors(), CloneBlobInfo(), CloneDrawInfo(), CloneExceptionInfo(), CloneImage(), CloneImageView(), CloneKernelInfo(), CloneMontageInfo(), CloneQuantizeInfo(), ConvertPathToPolygon(), DrawImage(), GetCubeInfo(), GetImageDynamicThreshold(), GetNodeInfo(), GetThresholdMapFile(), InitializeIntervalTree(), InsertValueInLinkedList(), InsertValueInSortedLinkedList(), ListFiles(), LoadCoderCache(), LoadColorCache(), LoadConfigureCache(), LoadDelegateCache(), LoadLocaleCache(), LoadLogCache(), LoadMagicCache(), LoadMimeCache(), LoadPolicyCache(), LoadTypeCache(), NewImageView(), NewImageViewRegion(), NewLinkedList(), NewSplayTree(), NewXMLTreeTag(), ParseInternalDoctype(), ParseProcessingInstructions(), RenderHoughLines(), ResizeMagickMemory(), SetImageInfo(), SetImageRegistry(), and ThrowException().

MagickExport void* AcquireQuantumMemory ( const size_t  count,
const size_t  quantum 
)

Definition at line 541 of file memory.c.

References AcquireMagickMemory(), CheckMemoryOverflow(), and MagickFalse.

Referenced by AcquireContributionThreadSet(), AcquireFxInfo(), AcquireFxThreadSet(), AcquireHistogramThreadSet(), AcquireImageColormap(), AcquireMagickMatrix(), AcquirePixelCacheNexus(), AcquirePixelChannelMap(), AcquirePixelList(), AcquirePixelListThreadSet(), AcquirePixelThreadSet(), AcquirePolygonThreadSet(), AcquireQuantumPixels(), AcquireRandomInfoThreadSet(), AcquireResampleFilterThreadSet(), AcquireSignatureInfo(), AcquireString(), AcquireStringInfo(), AcquireUniqueSymbolicLink(), BalanceSplayTree(), Base64Decode(), Base64Encode(), BlobToStringInfo(), Classify(), CloneDrawInfo(), CloneImage(), ClonePixelCacheOnDisk(), ClutImage(), ColorDecisionListImage(), CompareImagesLayers(), ConfigureFileToStringInfo(), ConnectedComponentsImage(), ConstantString(), ContrastStretchImage(), ConvertLatin1ToUTF8(), ConvertPathToPolygon(), ConvertPrimitiveToPath(), ConvertUTF16ToUTF8(), CopyDelegateFile(), CreateMagickThreadKey(), DeleteImages(), DeskewImage(), DistortImage(), DrawDashPolygon(), DrawImage(), EqualizeImage(), EscapeString(), ExpandFilenames(), ExportImagePixels(), FileToBlob(), FileToImage(), FileToXML(), GammaImage(), GaussJordanElimination(), GenerateCoefficients(), Get8BIMProperty(), GetCoderInfoList(), GetCoderList(), GetColorInfoList(), GetColorList(), GetCommandOptions(), GetConfigureInfoList(), GetConfigureList(), GetDelegateInfoList(), GetDelegateList(), GetExecutionPath(), GetEXIFProperty(), GetImageDepth(), GetImageDistortion(), GetImageDistortions(), GetImageDynamicThreshold(), GetImageFeatures(), GetImageHistogram(), GetImageMoments(), GetImagePerceptualHash(), GetImageStatistics(), GetImageViewException(), GetIPTCProperty(), GetLocaleInfoList(), GetLocaleList(), GetLocationStatistics(), GetLogInfoList(), GetLogList(), GetMagicInfoList(), GetMagickInfoList(), GetMagickList(), GetMagicList(), GetMimeInfoList(), GetMimeList(), GetNodeInfo(), GetPathComponents(), GetPolicyInfoList(), GetPolicyList(), GetThresholdMapFile(), GetTypeInfoList(), GetTypeList(), GetVirtualPixelsFromNexus(), GradientImage(), HuffmanDecodeImage(), HuffmanEncodeImage(), IdentifyImage(), ImageListToArray(), ImagesToBlob(), ImageToBlob(), ImageToFile(), ImportImagePixels(), InitializeIntervalTree(), InjectImageBlob(), IterateOverSplayTree(), LinearStretchImage(), ListFiles(), LZWEncodeImage(), MontageImageList(), MorphologyPrimitive(), MotionBlurImage(), NewXMLTree(), OptimalTau(), OptimizeLayerFrames(), PackbitsEncodeImage(), ParseEntities(), ParseInternalDoctype(), ParseKernelArray(), ParseProcessingInstructions(), PingBlob(), ReduceImageColors(), RotationalBlurImage(), SampleImage(), ScaleImage(), ScaleSpace(), SegmentImage(), SetGrayscaleImage(), SetImageDepth(), SetStringInfoLength(), SetXMLTreeAttribute(), SortColormapByIntensity(), sRGBTransformImage(), StreamImagePixels(), StringInfoToHexString(), StringInfoToString(), StringToArgv(), StringToArrayOfDoubles(), StringToList(), TraceBezier(), TraceStrokePolygon(), TransformsRGBImage(), WaveImage(), and WaveletDenoiseImage().

static MagickBooleanType CheckMemoryOverflow ( const size_t  count,
const size_t  quantum 
)
static
MagickExport void GetMagickMemoryMethods ( AcquireMemoryHandler acquire_memory_handler,
ResizeMemoryHandler resize_memory_handler,
DestroyMemoryHandler destroy_memory_handler 
)
MagickExport void* GetVirtualMemoryBlob ( const MemoryInfo memory_info)
MagickExport void* RelinquishMagickMemory ( void *  memory)

Definition at line 974 of file memory.c.

References BlockFooter, BlockHeader, _MagickMemoryMethods::destroy_memory_handler, LockSemaphoreInfo(), memory_methods, NextBlock, PreviousBlock, PreviousBlockBit, SizeMask, SizeOfBlock, and UnlockSemaphoreInfo().

Referenced by access_utf8(), AcquireCoderCache(), AcquireFxInfo(), AcquireMagickMatrix(), AcquirePolygonThreadSet(), AcquireQuantumPixels(), AcquireUniqueSymbolicLink(), AddPathToXMLTree(), AnnotateImage(), BalanceSplayTree(), Base64Decode(), CanonicalXMLContent(), Classify(), ClearLinkedList(), ClonePixelCacheOnDisk(), ClutImage(), ColorDecisionListImage(), CompareImagesLayers(), ConfigureFileToStringInfo(), ConnectedComponentsImage(), ContrastStretchImage(), ConvertPathToPolygon(), CopyDelegateFile(), CreateMagickThreadKey(), DeleteImages(), DeleteMagickThreadKey(), DeleteNodeByValueFromSplayTree(), DeleteNodeFromSplayTree(), DeskewImage(), DestroyBlob(), DestroyCoderNode(), DestroyColorCube(), DestroyColorElement(), DestroyConfigureElement(), DestroyContributionThreadSet(), DestroyCubeInfo(), DestroyDelegate(), DestroyDistributeCacheInfo(), DestroyDrawInfo(), DestroyEdge(), DestroyExceptionElement(), DestroyExceptionInfo(), DestroyFxInfo(), DestroyFxThreadSet(), DestroyHistogramThreadSet(), DestroyImage(), DestroyImageInfo(), DestroyImageView(), DestroyKernelInfo(), DestroyLinkedList(), DestroyLocaleNode(), DestroyLogElement(), DestroyMagicElement(), DestroyMagickNode(), DestroyMatrixInfo(), DestroyMimeElement(), DestroyMontageInfo(), DestroyPixelCache(), DestroyPixelCacheNexus(), DestroyPixelChannelMap(), DestroyPixelList(), DestroyPixelListThreadSet(), DestroyPixelStream(), DestroyPixelThreadSet(), DestroyPolicyElement(), DestroyPolygonInfo(), DestroyPolygonThreadSet(), DestroyQuantizeInfo(), DestroyQuantumInfo(), DestroyQuantumPixels(), DestroyRandomInfo(), DestroyRandomInfoThreadSet(), DestroyRegistryNode(), DestroyResampleFilter(), DestroyResampleFilterThreadSet(), DestroyResizeFilter(), DestroySignatureInfo(), DestroySplayTree(), DestroyStreamInfo(), DestroyString(), DestroyStringInfo(), DestroyStringList(), DestroyThresholdMap(), DestroyTimerInfo(), DestroyTokenInfo(), DestroyTypeNode(), DestroyXMLTree(), DestroyXMLTreeAttributes(), DestroyXMLTreeRoot(), DistortImage(), DrawDashPolygon(), DrawImage(), DrawStrokePolygon(), EqualizeImage(), ExpandFilenames(), ExportImagePixels(), ExternalDelegateCommand(), FileToBlob(), FileToImage(), FileToStringInfo(), FileToXML(), fopen_utf8(), FreeNodes(), GammaImage(), GaussJordanElimination(), GenerateCoefficients(), GetConfigureOptions(), GetConfigurePaths(), GetDelegateCommand(), GetExecutionPath(), GetHostname(), GetImageDepth(), GetImageDistortion(), GetImageDistortions(), GetImageDynamicThreshold(), GetImageEntropy(), GetImageFeatures(), GetImageMean(), GetImageMoments(), GetImagePerceptualHash(), GetImageStatistics(), GetLocaleOptions(), GetMultilineTypeMetrics(), GetNormalizedCrossCorrelationDistortion(), GetNumberColors(), GetPerceptualHashDistortion(), GetVirtualPixelsFromNexus(), GetXMLTreePath(), GetXMPProperty(), HuffmanDecodeImage(), HuffmanEncodeImage(), IdentifyImage(), ImagesToBlob(), ImageToBlob(), ImageToFile(), ImportImagePixels(), InitializeIntervalTree(), InjectImageBlob(), InsertValueInSortedLinkedList(), InvokeDelegate(), IsOptionMember(), IterateOverSplayTree(), LinearStretchImage(), ListCoderInfo(), ListColorInfo(), ListConfigureInfo(), ListDelegateInfo(), ListFiles(), ListLocaleInfo(), ListLogInfo(), ListMagicInfo(), ListMagickInfo(), ListMimeInfo(), ListPolicyInfo(), ListTypeInfo(), LoadCoderCache(), LoadColorCache(), LoadConfigureCache(), LoadDelegateCache(), LoadLocaleCache(), LoadLogCache(), LoadMagicCache(), LoadPolicyCache(), LoadTypeCache(), LogMagickEventList(), LZWEncodeImage(), MontageImageList(), MorphologyPrimitive(), MotionBlurImage(), open_utf8(), OptimalTau(), OptimizeLayerFrames(), PackbitsEncodeImage(), ParseInternalDoctype(), PingBlob(), popen_utf8(), PreviewImage(), ReadInlineImage(), ReduceImageColors(), RelinquishMagickMatrix(), RelinquishVirtualMemory(), remove_utf8(), RemoveElementByValueFromLinkedList(), RemoveElementFromLinkedList(), RemoveLastElementFromLinkedList(), RemoveNodeByValueFromSplayTree(), RemoveNodeFromSplayTree(), rename_utf8(), ResetSplayTree(), ResizeMagickMemory(), ResizeQuantumMemory(), RotationalBlurImage(), SampleImage(), ScaleImage(), ScaleSpace(), SegmentImage(), SetGrayscaleImage(), SetImageArtifact(), SetImageDepth(), SetImageInfo(), SetImageOption(), SetImageProfileInternal(), SetImageProperty(), SetImageRegistry(), SortColormapByIntensity(), SparseColorImage(), sRGBTransformImage(), stat_utf8(), StreamImagePixels(), StringToArgv(), TraceBezier(), TraceStrokePolygon(), TransformsRGBImage(), WaveImage(), and WaveletDenoiseImage().

MagickExport void* ResetMagickMemory ( void *  memory,
int  byte,
const size_t  size 
)

Definition at line 1105 of file memory.c.

Referenced by AcquireCoderCache(), AcquireColorCache(), AcquireConfigureCache(), AcquireContributionThreadSet(), AcquireDistributeCacheInfo(), AcquireFxInfo(), AcquireFxThreadSet(), AcquireHistogramThreadSet(), AcquireImage(), AcquireKernelBuiltIn(), AcquireLogCache(), AcquireMagicCache(), AcquireMagickInfo(), AcquireMagickMemory(), AcquireMatrixInfo(), AcquirePixelCacheNexus(), AcquirePixelChannelMap(), AcquirePixelList(), AcquirePixelListThreadSet(), AcquirePixelThreadSet(), AcquirePolicyCache(), AcquirePolygonThreadSet(), AcquireQuantumPixels(), AcquireRandomInfo(), AcquireRandomInfoThreadSet(), AcquireResampleFilter(), AcquireResampleFilterThreadSet(), AcquireResizeFilter(), AcquireSemaphoreInfo(), AcquireSignatureInfo(), AcquireStreamInfo(), AcquireStringInfo(), AcquireTimerInfo(), AcquireVirtualCacheView(), AcquireVirtualMemory(), AdaptiveBlurImage(), AdaptiveSharpenImage(), AddChildToXMLTree(), Ascii85Initialize(), CannyEdgeImage(), Classify(), CloneCacheView(), CloneImage(), CloneImageView(), ClonePixelCacheRepository(), ConnectedComponentsImage(), ConnectPixelCacheServer(), ContrastStretchImage(), ConvertPathToPolygon(), DespeckleImage(), DestroyMagickMemory(), DestroyRandomInfo(), DistortResizeImage(), DistributePixelCacheServer(), DitherImage(), EdgeImage(), EqualizeImage(), FinalizeSignature(), FormatMagickTime(), GammaImage(), GaussJordanElimination(), GetAbsoluteDistortion(), GetAffineMatrix(), GetBlobInfo(), GetCubeInfo(), GetDrawInfo(), GetFuzzDistortion(), GetImageDistortion(), GetImageDistortions(), GetImageDynamicThreshold(), GetImageFeatures(), GetImageInfo(), GetImageMoments(), GetImageQuantizeError(), GetImageStatistics(), GetLocationStatistics(), GetMeanAbsoluteDistortion(), GetMeanSquaredDistortion(), GetMontageInfo(), GetMultilineTypeMetrics(), GetNodeInfo(), GetPathAttributes(), GetPeakAbsoluteDistortion(), GetPixelCacheMethods(), GetQuantizeInfo(), GetQuantumInfo(), GetTimerInfo(), GetTypeMetrics(), GetVirtualPixelsFromNexus(), HuffmanEncodeImage(), InitializeExceptionInfo(), InitializePixelChannelMap(), InterpolatePixelInfo(), LinearStretchImage(), LoadCoderCache(), LoadColorCache(), LoadConfigureCache(), LoadDelegateCache(), LoadLocaleCache(), LoadLogCache(), LoadMagicCache(), LoadMimeCache(), LoadPolicyCache(), LoadTypeCache(), MontageImageList(), NewImageView(), NewImageViewRegion(), NewLinkedList(), NewSplayTree(), NewXMLTreeTag(), NullMatrix(), OilPaintImage(), OpenBlob(), ParseKernelArray(), PopDoublePixel(), PopFloatPixel(), QueryColorCompliance(), ResetStringInfo(), ScaleImage(), SetGeometry(), SetGeometryInfo(), SetGrayscaleImage(), SetImageColorspace(), SetImageInfo(), SetImageRegistry(), SetStringInfo(), SharpenImage(), sRGBTransformImage(), ThrowException(), TracePSClippath(), TraceSVGClippath(), TransformSignature(), and WriteStreamImage().

MagickExport void SetMagickMemoryMethods ( AcquireMemoryHandler  acquire_memory_handler,
ResizeMemoryHandler  resize_memory_handler,
DestroyMemoryHandler  destroy_memory_handler 
)

Variable Documentation

MagickMemoryMethods memory_methods
static
Initial value:
=
{
}
void *(* AcquireMemoryHandler)(size_t) magick_alloc_size(1)
Definition: memory_.h:29
void *(*)(* DestroyMemoryHandler)(void *)
Definition: memory_.h:30
void *(*)(*)*(* ResizeMemoryHandler)(void *, size_t) magick_alloc_size(2)
Definition: memory_.h:31

Definition at line 182 of file memory.c.

Referenced by AcquireMagickMemory(), DestroyMagickMemory(), GetMagickMemoryMethods(), RelinquishMagickMemory(), ResizeMagickMemory(), and SetMagickMemoryMethods().