コード例 #1
0
ファイル: testDir_win32.c プロジェクト: Sektor/phoneme-qtopia
static int init() {
    int res;

    res = pcsl_file_init();
    if (res < 0 ) {
    	printf("Can't init the heap\n");
    	return -1;
    } else if (res == 0) {
    	printf("Already initialized\n");
    }
    return 0;
}
コード例 #2
0
ファイル: midpStorage.c プロジェクト: sfsy1989/j2me
/*
 * Prefixing the system directory for storage, APP_DIR, with midp_home.
 *
 * @param midp_home file system path to where MIDP is installed
 *
 * @return 0 for success, non-zero for out of memory
 */
int
storageInitialize(char *midp_home) {
    jchar fsep = storageGetFileSeparator();

    if (storageInitDone) {
        /* Already initialized */
        return 0;
    }

    if (PCSL_STRING_OK != pcsl_string_initialize()) {
        REPORT_ERROR(LC_CORE, "Error: cannot initialize string library.\n");
        return -1;
    }

    if(pcsl_file_init() < 0)  {
        REPORT_ERROR(LC_CORE, "Error: out of memory.\n");
        return -1;
    }

    /* set up a path to the internal storage */
    if (PCSL_STRING_OK != pcsl_string_from_chars(midp_home, &sRoot[0])) {
        REPORT_ERROR(LC_CORE, "Error: out of memory.\n");
        storageFinalize();
        return -1;
    }

    /* performance hint: predict buffer capacity */
    pcsl_string_predict_size(&sRoot[0], pcsl_string_length(&sRoot[0]) + 2
                                    + PCSL_STRING_LITERAL_LENGTH(APP_DIR));
    if (PCSL_STRING_OK != pcsl_string_append_char(&sRoot[0], fsep)
     || PCSL_STRING_OK != pcsl_string_append(&sRoot[0], &APP_DIR)
     || PCSL_STRING_OK != pcsl_string_append_char(&sRoot[0], fsep)) {
        REPORT_ERROR(LC_CORE, "Error: out of memory.\n");
        storageFinalize();
        return -1;
    }

    if (0 != initializeConfigRoot(midp_home)) {
        storageFinalize();
        return -1;
    }

    storageInitDone = 1;
    return 0;
}