Back to mnoGoSearch site

UdmAgentInit

Name

UdmAgentInit -- Allocates or initializes a search session variable

Description

UDM_AGENT* UdmAgentInit(UDM_AGENT* Agent, UDM_ENV* Env, int id);

Allocates or initializes an UDM_AGENT variable (search session).

If Agent is a NULL pointer, the function allocates, initializes, and returns a new variable. Otherwise, the variable is initialized and the address of the variable is returned. If UdmAgentInit() allocates a new variable, it is freed when UdmAgentFree() is called to close search session.

Parameters

Agent

Pointer to a variable of type UDM_AGENT.

Env

Pointer to a variable of type UDM_ENV, should be the address of an existing UDM_ENV structure. Before calling UdmAgentInit() you must previously call UdmEnvInit() to initialize the UDM_ENV structure.

id

Thread id - an unique positive integer for a multi-thread application, or 0 in a non-thread application.

Return Values

Pointer to initialized UDM_AGENT variable on success, NULL there was insufficient memory to allocate a new variable.

Examples

Example 1. UdmAgentInit example #1


UDM_AGENT *Agent;

if (!(Agent= UdmAgentInit(NULL, Env, 0)))
{
  printf('Fatal error: could not allocate Agent');
  exit(1);
}
...
UdmAgentFree(Agent);

    

Example 2. UdmAgentInit example #2


UDM_AGENT Agent;

if (!UdmEnvInit(&Agent))
{
  printf('Fatal error: could not initialize Agent');
  exit(1);
}
...
UdmAgentFree(&Agent);

    

Notes

In a multi-threaded application, multiple search session variables can share the same search context variable.

See Also

UdmEnvInit
UdmEnvFree
UdmAgentFree