UnlockComplex

Top  Previous  Next

Syntax

 

UnlockComplex(<complextData>)

 

Parameters

 

<complexData>

 

A value or a (nested) array of values.

 

Return value

 

Always NIL.

 

Description

 

UnlockComplex calls the :Unlock() method of all structures contained in <complexData>. It is used in conjunction with Complex2Buffer to release memory that was allocated for pointer members of structures in <complexData>. Unlike Buffer2Complex, UnlockComplex skips reading back the pointer data by passing .F. to  :Unlock().

 

Classification

 

Core

 

Category

 

Array and String Utility

 

Quick Info

 

Library: cckptcor.lib / cckptcor.dll

Header: StringTypes.ch

 

See also

 

Complex2Buffer

 

Example

 

 

#INCLUDE "CockpitCoreLibs.ch"

#INCLUDE "CockpitPlatformLibs.ch"

#INCLUDE "ExtendedStructures.ch"

 

FUNCTION Main

 

LOCAL complexData

LOCAL buffer

LOCAL value := XS():New()

 

* Assign a string to allocate memory for

value:data := "My goodness, a string!"

 

* Put together the complex value

complexData := {value}

 

* Now put together the buffer string

buffer := Complex2Buffer(complexData)

 

* This should show our string

? CopyMemoryToString(Bin2L(buffer))

 

* Let's check the memory address used for the string, should be # 0

? value:address_data

 

* Now release the allocated memory

UnlockComplex(complexData)

 

* After release the memory address should be 0

? value:address_data

 

RETURN NIL

 

 

* This is our test structure

MEMBERLIST XS

PTR MEMBER data

ENDMEMBERLIST

 

STRUCTURE XS

PTR STRING data

ENDSTRUCTURE