Macros

This section describes the macros defined for the DMA specification.

DMA_CREATE_STRING

Syntax
void DMA_CREATE_STRING (
void* _allocfn(size_t),
const DmaUInteger32 _charcount,
const DmaWChar * _srcwchars,
ppDmaString _ppstr)

Parameters

Name

Mode

Description

_allocfn(size_t)

input

A pointer to allocator function.

_charcount

input

The number of DmaWChar characters supplied in srcwchars.

_srcwchars

input

The source character string for initializing the DmaString.

_ppstr

output

pointer to where the pDmaString of the new string is delivered

Description

This is a macro. Clients should assume this macro (which is a little intricate) is a block of code. Clients should not assume it is a function or expression, even though its behavior is as if it is implemented by a procedure.

DMA_CREATE_STRING creates a new DmaString using the supplied allocator. Because DMA_CREATE_STRING is a macro, the supplied allocator can be a method on an interface (e.g., imalloc->Alloc). The initial value of the string is a copy of the first _charcount characters of _srcwchars. The pointer to the constructed DmaString is delivered into the output location, _ppstr.

The input arguments must be valid. The macros are NOT expected to check for valid input arguments. The macro will either succeed or return with *_ppstr set to NULL.

DMA_FREE_STRING

Syntax
void DMA_FREE_STRING (
void _freeFn( void *memblock ),
pDmaString _pstr)

Parameters

Name

Mode

Description

_freeFn( void *memblock )

input

The pointer to the function to be used for freeing the memory

_pstr

input

The pointer to the DmaString to be freed

Description

This is a macro. Clients should assume this macro is a block of code. Clients should not assume it is a function or expression.

The macro free’s the DmaString using the specified de-allocator. It is legal to supply a NULL _pstr value, in which case the macro perform no operation.

There are no error returns.

DMA_GET_STRING_CHAR_COUNT

Syntax
DmaUInteger32 DMA_GET_STRING_CHAR_COUNT (
const pDmaString _pstr)

Parameters

Name

Mode

Description

_pstr

input

The DmaString

Description

This is a macro. Clients can safely assume this macro is an expression.

The macro returns the number of characters in the string. The terminating NULL of a string is not counted.

There are no error returns. The macro returns 0 if a NULL input is supplied.

DMA_GET_STRING_TEXT

Syntax
const DmaWChar* DMA_GET_STRING_TEXT (
pDmaString _pstr)

Parameters

Name

Mode

Description

_pstr

input

The DmaString

Description

This is a macro. Clients can safely assume this macro is an expression.

The macro returns a pointer to a sequence of characters. There is a null character at the end.

There are no error returns. The macro returns NULL, if a NULL input is supplied.