Alloc

IVI Library

Ivi_Alloc

Usage

ViStatus Ivi_Alloc(ViSession vi, ViInt32 Memory_Block_Size, ViAddr* Memory_Block_Pointer);

Purpose

This function allocates memory for an object of the size you specify and initializes all bytes to zero. If you specify a non-NULL IVI session handle, the function associates the memory block with the session by inserting it into the list of memory blocks the IVI engine maintains for the session.

You can call Ivi_Free to free the memory block. You can call Ivi_FreeAll to free all of the memory blocks that you allocate for the session with Ivi_Alloc or Ivi_RangeTableNew. When you call Ivi_Dispose on the session, it calls Ivi_FreeAll for you.

If the function cannot allocate the space or you pass 0 for the Memory Block Size parameter, the function sets the Memory Block Pointer parameter to VI_NULL and returns an error.

Parameters

Name Type Description
vi ViSession

If you want to associate the memory block with a particular IVI session, pass the IVI session handle that you obtain from Ivi_SpecificDriverNew. Otherwise, pass VI_NULL.

Memory_Block_Size ViInt32

Specify the number of bytes you want to allocate. You must pass a non-zero value.

Memory_Block_Pointer ViAddr*

Returns a pointer to the memory block the function allocates.

If the function cannot allocate the space or you pass 0 for the Memory Block Size parameter, this parameter returns VI_NULL and the function returns an error.

Return Value

Contains the status code that the function call returns. IVI engine functions can return error and warning values from several sets of status codes. Some status codes are unique to the IVI engine. Other status codes are the same codes that VISA Library functions return. Still others are error or warning values that functions in specific instrument drivers return. Each set of status codes has its own numeric range.

Regardless of the source of the status code, 0 always indicates success, a positive value indicates a warning, and a negative value indicates an error.

Related Topic

IVI Status Codes