Allocating a DBCOMMANDTREE Structure
Note
Indexing Service is no longer supported as of Windows XP and is unavailable for use as of Windows 8. Instead, use Windows Search for client side search and Microsoft Search Server Express for server side search.
The following example declares a function PctAllocNode to allocate a new DBCOMMANDTREE structure. An additional example in Setting Up a Condition Subtree uses the function.
DBCOMMANDTREE* PctAllocNode(
DBOP op,
DBVALUEKIND eKind,
ULONG cbValueSize
)
{
DBCOMMANDTREE* pct;
//get the OLE IMalloc interface
IMalloc* pim;
HRESULT hr = CoGetMalloc(MEMCTX_TASK, &pim);
if (FAILED(hr))
return NULL;
// Allocate fixed size part of the node
pct = (DBCOMMANDTREE*)pim->Alloc((sizeof DBCOMMANDTREE));
//initialize fields
pct->op = op;
pct->pctFirstChild = NULL;
pct->pctNextSibling = NULL;
pct->hrError = S_OK;
pct->dwKind = eKind;
// Allocate variable size part of the node
if ( 0 != cbValueSize )
pct.value.pvValue = (void *) pim->Alloc(cbValueSize);
//Initialize value space
if (0 != cbValueSize)
memset(pct->value.pvValue, 0, cbValueSize);
return pct;
}