MappAlloc()函数

Synopsis

Allocate a MIL application.

Format

MIL_ID MappAlloc(InitFlag, ApplicationIdPtr)

long InitFlag; Initialization flag
MIL_ID *ApplicationIdPtr; Storage location for application identifier

Description

This function allocates a MIL application. A MIL application must be allocated prior to using any other MIL functions. The MIL functions use the first application that was user-allocated.

The InitFlag parameter specifies the type of initialization to perform on the MIL application. This parameter should be set to one of the following values:

M_DEFAULT Default initialization.
M_QUIET Suppress the displaying of error messages during the allocation of the application.

The ApplicationIdPtr parameter specifies the address of the variable in which the application identifier is to be written. Since the MappAlloc function also returns the application identifier, you can set this parameter to M_NULL. If allocation fails, M_NULL is written as the identifier.

In multi-thread environments, the application is shared by all threads and “Mapp…” function calls from any thread apply to all threads unless specifically localized to that thread by specifying an M_THREAD_CURRENT flag when calling the function. However, if a new MIL application is allocated within a thread, using MappAlloc, this thread will be isolated from the shared application and all application controls and hooks will be independent. For example, turning off the error print in the new thread, using MappControl, will not affect the printing of errors by the original shared application; nor will such a command called from a thread attached to the original application affect the new application.

Note, upon allocation of a MIL application, a default system (M_SYSTEM_HOST) is automatically allocated. This default Host system can be used in MIL function calls by specifying M_DEFAULT_HOST wherever a system identifier is required.

In addition, a default graphic context is also allocated upon allocation of a MIL application. This default graphic context can be used in MIL graphic function calls by specifying M_DEFAULT wherever a graphic context identifier is required.

In multi-thread applications, a default graphic context is allocated for each thread in order to avoid inter-thread interference.

Return value

The returned value is the application identifier. If allocation fails, M_NULL is returned as the identifier.

See also

MappFree, MappAllocDefault

《MappAlloc()函数》上有26条评论

评论已关闭。