frags_t Obsolete Device API Types and Functions
API Reference Manual  /  Device API  /  Device API Functions  / 

Dynamic Memory Management

MM_FREE

Name

MM_FREE — free allocation

Synopsis

C and DML

#include <simics/device-api.h> // in C
// not available in DML

MM_FREE(p);

Description

MM_FREE frees an allocation previously made with MM_MALLOC, MM_MALLOC_SZ, MM_ZALLOC, MM_ZALLOC_SZ, MM_REALLOC, MM_REALLOC_SZ or MM_STRDUP.

A null pointer argument is legal, in which case nothing happens.

Execution Context

All contexts (including Threaded Context)

MM_MALLOC, MM_MALLOC_SZ, MM_ZALLOC, MM_ZALLOC_SZ

Name

MM_MALLOC, MM_MALLOC_SZ, MM_ZALLOC, MM_ZALLOC_SZ — allocate memory

Synopsis

C and DML

#include <simics/device-api.h> // in C
// not available in DML

MM_MALLOC(nelems, type);
MM_MALLOC_SZ(size, type);
MM_ZALLOC(nelems, type);
MM_ZALLOC_SZ(size, type);

Description

MM_MALLOC allocates nelems objects of type type. MM_MALLOC_SZ specifies the total allocation size in bytes.

MM_ZALLOC and MM_ZALLOC_SZ do the same thing as MM_MALLOC and MM_MALLOC_SZ respectively but in addition fill the allocated memory with null bytes.

If nelems or size are zero, either a null pointer or a pointer to a zero-sized allocation is returned.

Return Value

Pointer to the allocated object(s).

Execution Context

All contexts (including Threaded Context)

MM_REALLOC, MM_REALLOC_SZ

Name

MM_REALLOC, MM_REALLOC_SZ — reallocate memory

Synopsis

C and DML

#include <simics/device-api.h> // in C
// not available in DML

MM_REALLOC(p, nelems, type);
MM_REALLOC_SZ(p, size, type);

Description

MM_REALLOC changes the size of an allocated memory block to nelems elements. MM_REALLOC_SZ specifies the new size in bytes.

The allocation must originally have been made by a call to MM_MALLOC, MM_MALLOC_SZ, MM_ZALLOC, MM_ZALLOC_SZ, MM_REALLOC, MM_REALLOC_SZ or MM_STRDUP.

If the passed pointer is null, then these macros are equivalent to an allocation of the desired amount. If nelems or size is zero, either a null pointer or a pointer to a zero-sized allocation is returned, and the original allocation is freed.

The allocation must be freed using MM_FREE.

Return Value

Pointer to the reallocated object(s).

Execution Context

All contexts (including Threaded Context)

MM_STRDUP

Name

MM_STRDUP — duplicate a string

Synopsis

C and DML

#include <simics/device-api.h> // in C
// not available in DML

MM_STRDUP(str);

Description

Allocates and initializes a copy of the null-terminated string str. The allocation must be freed with MM_FREE.

Return Value

Pointer to the newly allocated string.

Execution Context

All contexts (including Threaded Context)

frags_t Obsolete Device API Types and Functions