Data Structures | Defines | Typedefs | Functions | Variables

memory.c File Reference

#include "magick/studio.h"
#include "magick/blob.h"
#include "magick/blob-private.h"
#include "magick/exception.h"
#include "magick/exception-private.h"
#include "magick/memory_.h"
#include "magick/semaphore.h"
#include "magick/string_.h"
Include dependency graph for memory.c:

Go to the source code of this file.

Data Structures

struct  _DataSegmentInfo
struct  _MemoryInfo
struct  _MagickMemoryMethods

Defines

#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 AlignedSize   (16*sizeof(void *))
#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)

Typedefs

typedef struct _DataSegmentInfo DataSegmentInfo
typedef struct _MemoryInfo MemoryInfo
typedef struct _MagickMemoryMethods MagickMemoryMethods

Functions

static size_t MagickMax (const size_t x, const size_t y)
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 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 * RelinquishAlignedMemory (void *memory)
MagickExport void * RelinquishMagickMemory (void *memory)
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

Define Documentation

#define AlignedSize   (16*sizeof(void *))

Definition at line 73 of file memory.c.

Referenced by AcquireAlignedMemory().

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

Definition at line 68 of file memory.c.

Referenced by RelinquishMagickMemory().

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

Definition at line 70 of file memory.c.

Referenced by RelinquishMagickMemory().

#define BlockSize   4096

Definition at line 71 of file memory.c.

#define BlockThreshold   1024

Definition at line 72 of file memory.c.

#define MaxBlockExponent   16

Definition at line 74 of file memory.c.

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

Definition at line 75 of file memory.c.

#define MaxSegments   1024

Definition at line 76 of file memory.c.

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

Definition at line 77 of file memory.c.

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

Definition at line 78 of file memory.c.

Referenced by RelinquishMagickMemory().

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

Definition at line 79 of file memory.c.

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

Definition at line 80 of file memory.c.

Referenced by RelinquishMagickMemory().

#define PreviousBlockBit   0x01

Definition at line 81 of file memory.c.

Referenced by RelinquishMagickMemory().

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

Definition at line 82 of file memory.c.

#define SegmentSize   (2*1024*1024)

Definition at line 83 of file memory.c.

#define SizeMask   (~0x01)

Definition at line 84 of file memory.c.

Referenced by AcquireMagickMemory().

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

Definition at line 85 of file memory.c.

Referenced by RelinquishMagickMemory().


Typedef Documentation

typedef struct _MemoryInfo MemoryInfo

Function Documentation

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

Definition at line 197 of file memory.c.

References AlignedSize, and MagickMax().

Referenced by AcquireCacheView(), AcquireContributionThreadSet(), AcquireDrawInfo(), AcquireExceptionInfo(), AcquireFxInfo(), AcquireFxThreadSet(), AcquireHistogramThreadSet(), AcquireImage(), AcquireImageInfo(), AcquireMedianPixelList(), AcquireMedianPixelListThreadSet(), AcquirePixelCache(), AcquirePixelCacheNexus(), AcquirePixelThreadSet(), AcquirePolygonThreadSet(), AcquireQuantizeInfo(), AcquireQuantumInfo(), AcquireRadonInfo(), AcquireRandomInfo(), AcquireRandomInfoThreadSet(), AcquireResampleFilterThreadSet(), AcquireResizeFilter(), AcquireSignatureInfo(), AcquireStreamInfo(), AcquireStringInfo(), AcquireTimerInfo(), AcquireTokenInfo(), AddChildToXMLTree(), AddValueToSplayTree(), AllocateSemaphoreInfo(), AppendValueToLinkedList(), Ascii85Initialize(), Classify(), CloneBlobInfo(), CloneCacheView(), CloneDrawInfo(), CloneImage(), CloneImageView(), CloneMagickPixelPacket(), CloneMontageInfo(), CloneQuantizeInfo(), ConvertPathToPolygon(), DrawImage(), GetCubeInfo(), GetImageAttribute(), GetImageDynamicThreshold(), GetNodeInfo(), GetThresholdMapFile(), InitializeIntervalTree(), InsertValueInLinkedList(), InsertValueInSortedLinkedList(), ListFiles(), LoadCoderList(), LoadCoderLists(), LoadColorList(), LoadColorLists(), LoadLocaleList(), LoadLogList(), LoadLogLists(), LoadMagicList(), LoadMagicLists(), LoadMimeList(), LoadPolicyList(), LoadPolicyLists(), LoadTypeList(), MagickCreateThreadKey(), NewHashmap(), NewImageView(), NewImageViewRegion(), NewLinkedList(), NewSplayTree(), NewXMLTreeTag(), ParseInternalDoctype(), ParseProcessingInstructions(), PutEntryInHashmap(), SetImageRegistry(), SetMagickInfo(), ThrowException(), XGetWindowImage(), and XInitializeWindows().

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

Definition at line 463 of file memory.c.

References AcquireMagickMemory().

Referenced by AcquireContributionThreadSet(), AcquireFxInfo(), AcquireHistogramThreadSet(), AcquireImageColormap(), AcquireKernelBuiltIn(), AcquireMagickMatrix(), AcquireMedianPixelList(), AcquirePixelThreadSet(), AcquireQuantumPixels(), AcquireSignatureInfo(), AcquireString(), AcquireStringInfo(), AcquireUniqueSymbolicLink(), AdaptiveBlurImageChannel(), AdaptiveSharpenImageChannel(), AllocateString(), BalanceSplayTree(), Base64Decode(), Base64Encode(), Classify(), CloneDrawInfo(), CloneImage(), CloneKernelInfo(), ColorDecisionListImage(), ColorFloodfillImage(), CompareImageLayers(), ConfigureFileToStringInfo(), ConstantString(), ContrastStretchImageChannel(), ConvertLatin1ToUTF8(), ConvertPathToPolygon(), ConvertPrimitiveToPath(), ConvertUTF16ToUTF8(), ConvolveImageChannel(), CopyDelegateFile(), DeleteImages(), DeskewImage(), DistortImage(), DrawDashPolygon(), DrawImage(), EdgeImage(), EmbossImage(), EqualizeImageChannel(), EscapeString(), ExpandFilenames(), ExportImagePixels(), FileToBlob(), FileToImage(), FloodfillPaintImage(), FloydSteinbergDither(), FontToList(), GammaImageChannel(), GaussianBlurImageChannel(), GaussJordanElimination(), GenerateCoefficients(), Get8BIMProperty(), GetBlurKernel(), GetCoderInfoList(), GetCoderList(), GetColorInfoList(), GetColorList(), GetConfigureInfoList(), GetConfigureList(), GetCubeInfo(), GetDelegateInfoList(), GetDelegateList(), GetExecutionPath(), GetEXIFProperty(), GetImageChannelDepth(), GetImageChannelDistortion(), GetImageChannelDistortions(), GetImageChannelFeatures(), GetImageChannelStatistics(), GetImageDynamicThreshold(), GetImageHistogram(), GetImageViewException(), GetIPTCProperty(), GetLocaleInfoList(), GetLocaleList(), GetLogInfoList(), GetLogList(), GetMagicInfoList(), GetMagickInfoList(), GetMagickList(), GetMagickOptions(), GetMagicList(), GetMimeInfoList(), GetMimeList(), GetMotionBlurKernel(), GetNodeInfo(), GetPathComponents(), GetPolicyInfoList(), GetPolicyList(), GetThresholdMapFile(), GetTypeInfoList(), GetTypeList(), GradientImage(), HuffmanDecodeImage(), HuffmanEncodeImage(), IdentifyImage(), ImageListToArray(), ImagesToBlob(), ImageToBlob(), ImageToFile(), ImportImagePixels(), IncreaseHashmapCapacity(), InitializeIntervalTree(), InjectImageBlob(), IterateOverSplayTree(), LinearStretchImage(), ListFiles(), LZWEncodeImage(), MatteFloodfillImage(), MontageImageList(), MotionBlurImageChannel(), NewHashmap(), NewXMLTree(), OptimalTau(), OptimizeLayerFrames(), PackbitsEncodeImage(), ParseEntities(), ParseInternalDoctype(), ParseKernelArray(), ParseProcessingInstructions(), PingBlob(), RadialBlurImageChannel(), RGBTransformImage(), SampleImage(), ScaleImage(), ScaleSpace(), SegmentImage(), SelectiveBlurImageChannel(), SetGrayscaleImage(), SetStringInfoLength(), SetXMLTreeAttribute(), SharpenImageChannel(), SigmoidalContrastImageChannel(), SortColormapByIntensity(), StreamImagePixels(), StringInfoToHexString(), StringInfoToString(), StringToArgv(), StringToList(), TraceBezier(), TraceStrokePolygon(), TransformRGBImage(), WaveImage(), XBestPixel(), XCommandWidget(), XDitherImage(), XFontBrowserWidget(), XGetPixelPacket(), XGetWindowImage(), XGetWindowInfo(), XMakeImage(), and XMakeStandardColormap().

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 
)
static size_t MagickMax ( const size_t  x,
const size_t  y 
) [inline, static]

Definition at line 190 of file memory.c.

Referenced by AcquireAlignedMemory().

MagickExport void* RelinquishAlignedMemory ( void *  memory  ) 
MagickExport void* RelinquishMagickMemory ( void *  memory  ) 

Definition at line 749 of file memory.c.

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

Referenced by AcquireFxInfo(), AcquireMagickMatrix(), AcquirePolygonThreadSet(), AcquireUniqueFileResource(), AcquireUniqueSymbolicLink(), AdaptiveBlurImageChannel(), AdaptiveSharpenImageChannel(), AddPathToXMLTree(), AnnotateImage(), BalanceSplayTree(), Base64Decode(), BlurImageChannel(), CanonicalXMLContent(), Classify(), ClearLinkedList(), CloneDiskToDiskPixelCache(), CloneDiskToMemoryPixelCache(), CloneMemoryToDiskPixelCache(), ColorDecisionListImage(), ColorFloodfillImage(), CompareImageLayers(), ContrastStretchImageChannel(), ConvertPathToPolygon(), ConvolveImageChannel(), CopyDelegateFile(), DeleteImages(), DeleteNodeByValueFromSplayTree(), DeleteNodeFromSplayTree(), DeskewImage(), DestroyAttribute(), DestroyBlob(), DestroyCoderNode(), DestroyColorCube(), DestroyColorElement(), DestroyConfigureElement(), DestroyContributionThreadSet(), DestroyCubeInfo(), DestroyDelegate(), DestroyDrawInfo(), DestroyEdge(), DestroyExceptionElement(), DestroyExceptionInfo(), DestroyFxInfo(), DestroyHashmap(), DestroyHistogramThreadSet(), DestroyImage(), DestroyImageInfo(), DestroyImageView(), DestroyKernelInfo(), DestroyLinkedList(), DestroyLocaleNode(), DestroyLogElement(), DestroyMagicElement(), DestroyMagickNode(), DestroyMedianPixelList(), DestroyMimeElement(), DestroyMontageInfo(), DestroyPixelStream(), DestroyPixelThreadSet(), DestroyPolicyElement(), DestroyPolygonInfo(), DestroyQuantizeInfo(), DestroyQuantumInfo(), DestroyQuantumPixels(), DestroyRadonInfo(), DestroyRegistryNode(), DestroyResampleFilter(), DestroyResizeFilter(), DestroySignatureInfo(), DestroySplayTree(), DestroyStreamInfo(), DestroyString(), DestroyStringInfo(), DestroyStringList(), DestroyThresholdMap(), DestroyTimerInfo(), DestroyTokenInfo(), DestroyTypeNode(), DestroyXMLTree(), DestroyXMLTreeAttributes(), DestroyXResources(), DestroyXWidget(), DistortImage(), DrawDashPolygon(), DrawImage(), DrawStrokePolygon(), EdgeImage(), EmbossImage(), EqualizeImageChannel(), ExpandFilenames(), ExportImagePixels(), FileToBlob(), FileToImage(), FloodfillPaintImage(), FloydSteinbergDither(), FreeNodes(), GammaImageChannel(), GaussianBlurImageChannel(), GaussJordanElimination(), GenerateCoefficients(), GetConfigureOptions(), GetConfigurePaths(), GetDelegateCommand(), GetExecutionPath(), GetImageAttribute(), GetImageChannelDepth(), GetImageChannelDistortion(), GetImageChannelFeatures(), GetImageChannelMean(), GetImageDynamicThreshold(), GetLocaleOptions(), GetMagickProperty(), GetMultilineTypeMetrics(), GetNumberColors(), GetPathAttributes(), GetXMLTreePath(), GetXMPProperty(), HuffmanDecodeImage(), HuffmanEncodeImage(), IdentifyImage(), ImageToFile(), ImportImagePixels(), IncreaseHashmapCapacity(), InitializeIntervalTree(), InjectImageBlob(), InsertValueInSortedLinkedList(), InvokeDelegate(), IterateOverSplayTree(), LinearStretchImage(), ListCoderInfo(), ListColorInfo(), ListConfigureInfo(), ListDelegateInfo(), ListFiles(), ListLocaleInfo(), ListLogInfo(), ListMagicInfo(), ListMagickInfo(), ListMimeInfo(), ListPolicyInfo(), ListTypeInfo(), LoadCoderList(), LoadCoderLists(), LoadColorList(), LoadConfigureList(), LoadDelegateList(), LoadLocaleList(), LoadLogList(), LoadMagicList(), LoadPolicyList(), LoadTypeList(), LogMagickEventList(), LZWEncodeImage(), MagickDeleteThreadKey(), MatteFloodfillImage(), MontageImageList(), MotionBlurImageChannel(), OpenMagickStream(), OptimalTau(), OptimizeLayerFrames(), PackbitsEncodeImage(), ParseInternalDoctype(), PingBlob(), PreviewImage(), ProfileImage(), PutEntryInHashmap(), RadialBlurImageChannel(), ReacquireMemory(), ReadInlineImage(), RelinquishCacheNexusPixels(), RelinquishMagickMatrix(), RelinquishPixelCachePixels(), RelinquishStreamPixels(), RemoveElementByValueFromLinkedList(), RemoveElementFromLinkedList(), RemoveEntryFromHashmap(), RemoveLastElementFromLinkedList(), RemoveNodeByValueFromSplayTree(), RemoveNodeFromSplayTree(), ResetSplayTree(), ResizeMagickMemory(), ResizeQuantumMemory(), RGBTransformImage(), SampleImage(), ScaleImage(), ScaleSpace(), SegmentImage(), SelectiveBlurImageChannel(), SetGrayscaleImage(), SetImageArtifact(), SetImageOption(), SetImageProfile(), SetImageProperty(), SetImageRegistry(), SharpenImageChannel(), SigmoidalContrastImageChannel(), SortColormapByIntensity(), SparseColorImage(), StreamImagePixels(), StringToArgv(), SystemCommand(), TraceBezier(), TraceStrokePolygon(), TransformImages(), TransformRGBImage(), WaveImage(), XBestFont(), XBestPixel(), XColorBrowserWidget(), XCommandWidget(), XDestroyResourceInfo(), XDisplayImageInfo(), XDitherImage(), XFileBrowserWidget(), XFontBrowserWidget(), XFreeStandardColormap(), XGetPixelPacket(), XGetWindowImage(), XMakeStandardColormap(), and XSetWindows().

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

Definition at line 821 of file memory.c.

Referenced by AcquireCacheView(), AcquireContributionThreadSet(), AcquireFxInfo(), AcquireFxThreadSet(), AcquireHistogramThreadSet(), AcquireImage(), AcquireKernelBuiltIn(), AcquireMagickMemory(), AcquireMedianPixelList(), AcquireMedianPixelListThreadSet(), AcquirePixelCache(), AcquirePixelCacheNexus(), AcquirePixelThreadSet(), AcquirePolygonThreadSet(), AcquireQuantumPixels(), AcquireRadonInfo(), AcquireRandomInfo(), AcquireRandomInfoThreadSet(), AcquireResampleFilter(), AcquireResampleFilterThreadSet(), AcquireSignatureInfo(), AcquireStreamInfo(), AcquireStringInfo(), AcquireTimerInfo(), AdaptiveBlurImageChannel(), AdaptiveSharpenImageChannel(), AddChildToXMLTree(), AllocateSemaphoreInfo(), Ascii85Initialize(), Classify(), CloneCacheView(), CloneDiskToDiskPixelCache(), CloneDiskToMemoryPixelCache(), CloneImage(), CloneImageView(), CloneMemoryToDiskPixelCache(), CloneMemoryToMemoryPixelCache(), ContrastStretchImageChannel(), ConvertPathToPolygon(), DespeckleImage(), DestroyMagickMemory(), DestroyRandomInfo(), DitherImage(), EnhanceImage(), EqualizeImageChannel(), FinalizeSignature(), FormatMagickTime(), GammaImageChannel(), GaussJordanElimination(), GetAbsoluteError(), GetAffineMatrix(), GetBlobInfo(), GetCubeInfo(), GetDrawInfo(), GetExceptionInfo(), GetImageAttribute(), GetImageChannelDistortion(), GetImageChannelDistortions(), GetImageChannelFeatures(), GetImageChannelStatistics(), GetImageDynamicThreshold(), GetImageInfo(), GetImageQuantizeError(), GetMeanAbsoluteError(), GetMeanSquaredError(), GetMontageInfo(), GetMultilineTypeMetrics(), GetNodeInfo(), GetPeakAbsoluteError(), GetPixelCacheMethods(), GetQuantizeInfo(), GetQuantumInfo(), GetTimerInfo(), GetTypeMetrics(), GradientImage(), HorizontalFilter(), HuffmanEncodeImage(), IdentityAffine(), IncreaseHashmapCapacity(), LinearStretchImage(), LoadCoderList(), LoadCoderLists(), LoadColorList(), LoadColorLists(), LoadConfigureList(), LoadConfigureLists(), LoadDelegateList(), LoadLocaleList(), LoadLogList(), LoadLogLists(), LoadMagicList(), LoadMagicLists(), LoadMimeList(), LoadPolicyList(), LoadPolicyLists(), LoadTypeList(), MontageImageList(), NewHashmap(), NewImageView(), NewImageViewRegion(), NewLinkedList(), NewSplayTree(), NewXMLTreeTag(), OilPaintImage(), OpenBlob(), ParseKernelArray(), QueryMagickColorCompliance(), ResetRadonCells(), ResetStringInfo(), RGBTransformImage(), ScaleImage(), SetGeometry(), SetGeometryInfo(), SetImageInfo(), SetImageRegistry(), SetMagickInfo(), SetStringInfo(), SigmoidalContrastImageChannel(), ThrowException(), TracePSClippath(), TraceSVGClippath(), TransformSignature(), VerticalFilter(), XDestroyResourceInfo(), XGetResourceInfo(), and XInitializeWindows().

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 
)

Variable Documentation

Initial value:
  {
    (AcquireMemoryHandler) malloc,
    (ResizeMemoryHandler) realloc,
    (DestroyMemoryHandler)free
  }

Definition at line 140 of file memory.c.

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