AcquireValue

PowerBuilder Native Interface

IPB_Session interface:

AcquireValue method

Description

Clones the data in the PBCallInfo structure and resets the IPB_Value pointer.

Syntax

AcquireValue ( IPBValue* value ) 

Argument

Description

value

The value to be returned

Return Values

IPB_Value*.

Examples

The AcquireValue method is used to obtain a message argument value. Later, when the value is no longer needed, it is released using ReleaseValue to avoid memory leaks:

// Acquire a value
MessageArg = session->AcquireValue
   ( ci->pArgs->GetAt(0) );
pbstring pbMessage = MessageArg->GetString() ;
Message = (LPSTR)session->GetString(pbMessage) ;
...
// Cleanup phase
if (MessageArg)
{
   Session->ReleaseValue ( MessageArg ) ;
}

Usage

The AcquireValue method enables you to retain the data in the PBCallInfo structure. The AcquireValue method is independent of the type of the data but is most useful for acquiring the value of pointer values such as pbvalue_string, pbvalue_blob, and so on. When you call FreeInfo, the data is not freed and the pointer returned by AcquireValue is still valid.If the value acquired is an array, the entire array is acquired. To acquire a single element in an array, use the AcquireItemValue method.When you no longer need the data, you must call the ReleaseValue method to free the data. Failing to do so causes a memory leak.The PBVM clones a new IPB_Value and resets the existing one. If you attempt to get or acquire the original value, the value returned is zero or null until another IPB_Value is set to the value.

See Also