Logo Search packages:      
Sourcecode: icu version File versions

U_STABLE void U_EXPORT2 u_init ( UErrorCode status )

Initialize ICU.

Use of this function is optional. It is OK to simply use ICU services and functions without first having initialized ICU by calling u_init().

u_init() will attempt to load some part of ICU's data, and is useful as a test for configuration or installation problems that leave the ICU data inaccessible. A successful invocation of u_init() does not, however, guarantee that all ICU data is accessible.

Multiple calls to u_init() cause no harm, aside from the small amount of time required.

In old versions of ICU, u_init() was required in multi-threaded applications to ensure the thread safety of ICU. u_init() is no longer needed for this purpose.

Parameters:
statusAn ICU UErrorCode parameter. It must not be NULL. An Error will be returned if some required part of ICU data can not be loaded or initialized. The function returns immediately if the input error code indicates a failure, as usual.

ICU 2.6

Definition at line 60 of file uinit.c.

References TRUE, and U_FAILURE.

                           {
    UTRACE_ENTRY_OC(UTRACE_U_INIT);
    /* initialize plugins */
    uplug_init(status);

    umtx_lock(&gICUInitMutex);
    if (gICUInitialized || U_FAILURE(*status)) {
        umtx_unlock(&gICUInitMutex);
        UTRACE_EXIT_STATUS(*status);
        return;
    }

    /*
     * 2005-may-02
     *
     * ICU4C 3.4 (jitterbug 4497) hardcodes the data for Unicode character
     * properties for APIs that want to be fast.
     * Therefore, we need not load them here nor check for errors.
     * Instead, we load the converter alias table to see if any ICU data
     * is available.
     * Users should really open the service objects they need and check
     * for errors there, to make sure that the actual items they need are
     * available.
     */
#if !UCONFIG_NO_CONVERSION
    ucnv_io_countKnownConverters(status);
#endif

    gICUInitialized = TRUE;    /* TODO:  don't set if U_FAILURE? */
    umtx_unlock(&gICUInitMutex);
    UTRACE_EXIT_STATUS(*status);
}

Generated by  Doxygen 1.6.0   Back to index