Navigation:  Reference > Functions By Category > Strings >

Array2ppMarshall()

Previous pageReturn to chapter overviewNext page

Array2ppMarshall( aStrings [, @aSizes] ) -> pMem

 

Array2ppMarshall() create a memory buffer to store the strings in the provided array.

The buffer will have the following structure.

 

LPSTR pStr1

....

LPSTR pStrN

DWORD 0

String1

...

StringN

 

The application is responsible to free this buffer using _xfree() when no longer required.

 

_marshall

 

<aStrings>

The needed Stringinfos for the marshall DLL.

<@aSizes> - optional

Optionally if the application provide the 2nd param , will retrieve an Xbase+ array with the size in bytes of every string.

 

See a snippet of code from libpq4xb.prg ( published in xfree.resources )

 

BEGIN STRUCTURE pqPrintOpt

 ..... other structure members ......

  MEMBER POINTER32 fieldName

  DYNAMIC METHOD SetFieldNames BLOCK {|s,a| _xfree(s:fieldName),;

                   s:fieldName := iif(a == NIL,0,Array2ppMarshall(a)) }

  DYNAMIC METHOD GetFieldNames BLOCK {|s| ppMarshall2Array(s:fieldName) }

END STRUCTURE

 

ppMarshall2Array(pArrayOfStringPointers  ) returns an Xbase++ array from a C array terminated with a NULL pointer.

Really the C string array not need to be marshalized as ppMarshall2Array()

does not deallocate the memory, but as the name indicate it is the reverse

function of Array2ppMarshall()

 

For more information about marshalling see here:

English:        http://en.wikipedia.org/wiki/Marshalling_(computer_science)

German:        http://en.wikipedia.org/wiki/Marshalling_(computer_science)