GraphicsMagick Search site

- Home
- License
- Mission
- Download
- Installation
- FAQ
- News
- Formats

- Process
- Contribute
- CVS
- Mailing Lists
- ChangeLog
- Report Bugs
- Utilities
- Programming
- Links

# memory

## Memory allocation/deallocation functions

Contents

- MagickAllocFunctions
- MagickMalloc
- MagickMallocCleared
- MagickCloneMemory
- MagickRealloc
- MagickFree

# MagickAllocFunctions

## Synopsis

    void MagickAllocFunctions( MagickFreeFunc free_func, MagickMallocFunc malloc_func,
                               MagickReallocFunc realloc_func );

## Description

MagickAllocFunctions() provides a way for the user to supply a preferred free(), malloc(), and realloc() functions. Otherwise the default system versions are used.

The format of the MagickAllocFunctions method is:

    void MagickAllocFunctions( MagickFreeFunc free_func, MagickMallocFunc malloc_func,
                               MagickReallocFunc realloc_func );

free_func:
  Function to free memory.
malloc_func:
  Function to allocate memory.
realloc_func:
  Function to reallocate memory.

# MagickMalloc

## Synopsis

    void *MagickMalloc( const size_t size );

## Description

MagickMalloc() returns a pointer to a block of memory of at least size bytes suitably aligned for any use. NULL is returned if insufficient memory is available or the requested size is zero.

The format of the MagickMalloc method is:

    void *MagickMalloc( const size_t size );

A description of each parameter follows:

size:
  The size of the memory in bytes to allocate.

# MagickMallocCleared

## Synopsis

    void *MagickMallocCleared( const size_t size );

## Description

MagickMallocCleared() returns a pointer to a block of memory of at least size bytes suitably aligned for any use. NULL is returned if insufficient memory is available or the requested size is zero. This version differs from MagickMalloc in that the allocated bytes are cleared to zero.

The format of the MagickMallocCleared method is:

    void *MagickMallocCleared( const size_t size );

A description of each parameter follows:

size:
  The size of the memory in bytes to allocate.

# MagickCloneMemory

## Synopsis

    void *MagickCloneMemory( void *destination, const void *source, const size_t size );

## Description

MagickCloneMemory() copies size bytes from memory area source to the destination. Copying between objects that overlap will take place correctly. It returns destination.

The format of the MagickCloneMemory method is:

    void *MagickCloneMemory( void *destination, const void *source, const size_t size );

A description of each parameter follows:

size:
  The size of the memory in bytes to allocate.

# MagickRealloc

## Synopsis

    void *MagickRealloc( void *memory, const size_t size );

## Description

MagickRealloc() changes the size of the memory and returns a pointer to the (possibly moved) block. The contents will be unchanged up to the lesser of the new and old sizes. If size is zero, then the memory is freed and a NULL value is returned. If the memory allocation fails, then the existing memory is freed, and a NULL value is returned.

The format of the MagickRealloc method is:

    void *MagickRealloc( void *memory, const size_t size );

A description of each parameter follows:

memory:
  A pointer to a memory allocation.
size:
  The new size of the allocated memory.

# MagickFree

## Synopsis

    void MagickFree( void *memory );

## Description

MagickFree() frees memory that has already been allocated. A NULL argument is ignored.

The format of the MagickFree method is:

    void MagickFree( void *memory );

A description of each parameter follows:

memory:
  A pointer to a block of memory to free for reuse.