VgwDocSetReadFreeFnc


Use the VgwDocSetReadFree function to destroy the table created by the VgwDocSetReadFnc function. The Verity engine calls your VgwDocSetReadFreeFnc function after the table has been returned.


Syntax

VdkError VgwDocSetReadFreeFnc (
   VgwDataTable   pvgwTable)

Arguments

 


pvgwTable

VgwDataTable A gateway VgwDataTable handle.


Member Descriptions

 

Table 8-4    VgwDataTableRec Members


session

VgwAppSession The session handle, which is passed in via the vgwSession argument.

numRows

VdkUint4 The number of documents in the values array.

numColumns

VdkUint2 The number of fields in the values array.

columnArray

VgwColumnInfo* A pointer to an array of VgwColumnInfo pointers that contain information about each field. (See VgwColumnInfoRec members below.)

values

VdkVoidp* A pointer to a table of values.

internal

VdkVoidp For internal use by the gateway.


 

Table 8-5    VgwColumnInfoRec Members


type

VdkFieldType The field data type flag. Valid values are:

VdkFieldType_Invalid for unsupported field names

VdkFieldType_Text for text strings

VdkFieldType_Signed for signed integers

VdkFieldType_Unsigned for unsigned integers

VdkFieldType_Date for VdkDate type data

VdkFieldType_Float for double floats

VdkFieldType_Stream for a binary blob of data

name

VdkCString Name of the external field.

size

VdkUint4 The data size, in bytes, or 0 for ASCIIZ (null-terminated strings).

flags

VdkUint2 Behavior flags, which are ORed together to specify how to treat this field when it is retrieved from the repository. You can set the following values:

VgwColumn_ReadOnly for field values that are not to be changed.

VgwColumn_Inline for fields that contain the actual value, not a pointer to the value.

VgwColumn_PrimaryKey for fields whose value is the primary key for the gateway; for example, the VdkVgwKey field should have this flag set

VgwColumn_RedirectFile for fields whose value is a the full pathname of a data file.

VgwColumn_Redirect_URL for fields whose value is a URL to a data file.

VgwColumn_Attachment for fields whose value is the full pathname to an attachment or subdocument.

internal

VdkVoidp For internal use by the gateway.

precedence

VdkInt2 Reserved for future use.



Returns

This function must return one of the following error codes:

VdkSuccess for success

 

VdkError_* for a standard Verity Developer Kit API error as described in the Verity Developer’s Kit Programming Reference

 


Discussion

Your VgwDocSetReadFreeFnc function must free the table specified by the pvgwTable argument and any structures associated with the table, such as the values associated with rows and columns in the table. Static structures need not be freed.


Example

static VdkError
VDK_CALLBACK VgwDocSetReadFree(VgwDataTable pTable)
{
VdkUint4 i;
VdkUint2 j;

if (!pTable)
return VdkSuccess;

/*****************************************************
* free memory allocated during docsetRead population
*****************************************************/

if (pTable->values) {
if (pTable->columnArray) {
for( i = 0; i < pTable->numRows; i++ )
for( j = 0; j < pTable->numColumns; j++ ){
if( !pTable->columnArray[j] )
continue;
if( !(pTable->columnArray[j]->flags & VgwColumn_InLine)
            && pTable->values[i*pTable->numColumns+j] )
free(pTable->values[i*pTable->numColumns+j]);
}
}
free(pTable->values);
}

/***************************************************
* no need to free static field column info members
***************************************************/

if (pTable->columnArray[0])
free(pTable->columnArray[0]);
if (pTable->columnArray)
free(pTable->columnArray);

/*****************************************
* free the data created in VgwDocSetRead
*****************************************/

free(pTable);
return VdkSuccess;
}