本文整理汇总了C++中pcsl_string_free函数的典型用法代码示例。如果您正苦于以下问题:C++ pcsl_string_free函数的具体用法?C++ pcsl_string_free怎么用?C++ pcsl_string_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pcsl_string_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_cleanup
/**
* The recursive helper function. It deletes all files inside specified
* directory and calls itself to delete subdirectories.
*
* @param pDirName the directory to delete
* @param pSep system-dependent file separator
*/
void do_cleanup(const pcsl_string* pDirName, const pcsl_string* pSep)
{
void* fileList = NULL;
pcsl_string fileName = PCSL_STRING_NULL;
pcsl_string dirName = PCSL_STRING_NULL;
// add tailing file separator to directory name
if (pcsl_string_cat(pDirName, pSep, &dirName) != PCSL_STRING_OK) {
return;
}
fileList = pcsl_file_openfilelist(&dirName);
if (fileList == NULL) {
pcsl_string_free(&dirName);
return;
}
// iterate over the directory's content
while (!pcsl_file_getnextentry(fileList, &dirName, &fileName)) {
int isDir = pcsl_file_is_directory(&fileName);
if (isDir == 1) {
// make recursion
do_cleanup(&fileName, pSep);
} else {
// remove file
pcsl_file_unlink(&fileName);
}
pcsl_string_free(&fileName);
};
pcsl_string_free(&dirName);
pcsl_file_closefilelist(fileList);
// remove empty directory
pcsl_file_rmdir(pDirName);
}
示例2: Java_com_sun_midp_content_RegistryStore_getHandler0
/**
* java call:
* private native String getHandler0(String callerId, String id, int mode);
*/
KNIEXPORT KNI_RETURNTYPE_OBJECT
Java_com_sun_midp_content_RegistryStore_getHandler0(void) {
int mode;
pcsl_string callerId = PCSL_STRING_NULL_INITIALIZER;
pcsl_string id = PCSL_STRING_NULL_INITIALIZER;
JSR211_RESULT_CH handler = _JSR211_RESULT_INITIALIZER_;
KNI_StartHandles(2);
KNI_DeclareHandle(callerObj);
KNI_DeclareHandle(handlerObj);
do {
KNI_GetParameterAsObject(1, callerObj);
KNI_GetParameterAsObject(2, handlerObj);
if (PCSL_STRING_OK != midp_jstring_to_pcsl_string(callerObj, &callerId) ||
PCSL_STRING_OK != midp_jstring_to_pcsl_string(handlerObj, &id)) {
KNI_ThrowNew(midpOutOfMemoryError,
"RegistryStore_getHandler0 no memory for string arguments");
break;
}
mode = KNI_GetParameterAsInt(3);
jsr211_get_handler(&callerId, &id, mode, &handler);
} while (0);
pcsl_string_free(&callerId);
pcsl_string_free(&id);
result2string((_JSR211_INTERNAL_RESULT_BUFFER_*)&handler, handlerObj);
KNI_EndHandlesAndReturnObject(handlerObj);
}
示例3: Java_com_sun_midp_content_RegistryStore_findHandler0
/**
* java call:
* private native String findHandler0(String callerId, int searchBy,
* String value);
*/
KNIEXPORT KNI_RETURNTYPE_OBJECT
Java_com_sun_midp_content_RegistryStore_findHandler0(void) {
pcsl_string callerId = PCSL_STRING_NULL_INITIALIZER;
jsr211_field searchBy;
pcsl_string value = PCSL_STRING_NULL_INITIALIZER;
JSR211_RESULT_CHARRAY result = _JSR211_RESULT_INITIALIZER_;
KNI_StartHandles(2);
KNI_DeclareHandle(callerObj);
KNI_DeclareHandle(valueObj);
do {
KNI_GetParameterAsObject(1, callerObj);
KNI_GetParameterAsObject(3, valueObj);
if (PCSL_STRING_OK != midp_jstring_to_pcsl_string(callerObj, &callerId) ||
PCSL_STRING_OK != midp_jstring_to_pcsl_string(valueObj, &value)) {
KNI_ThrowNew(midpOutOfMemoryError,
"RegistryStore_register0 no memory for string arguments");
break;
}
searchBy = (jsr211_field) KNI_GetParameterAsInt(2);
jsr211_find_handler(&callerId, searchBy, &value, &result);
} while (0);
pcsl_string_free(&value);
pcsl_string_free(&callerId);
result2string((_JSR211_INTERNAL_RESULT_BUFFER_*)&result, valueObj);
KNI_EndHandlesAndReturnObject(valueObj);
}
示例4: Java_com_sun_midp_content_RegistryStore_getByURL0
/**
* java call:
* private native String getByURL0(String callerId, String url, String action);
*/
KNIEXPORT KNI_RETURNTYPE_OBJECT
Java_com_sun_midp_content_RegistryStore_getByURL0(void) {
pcsl_string callerId = PCSL_STRING_NULL_INITIALIZER;
pcsl_string url = PCSL_STRING_NULL_INITIALIZER;
pcsl_string action = PCSL_STRING_NULL_INITIALIZER;
JSR211_RESULT_CH result = _JSR211_RESULT_INITIALIZER_;
KNI_StartHandles(4);
KNI_DeclareHandle(callerObj);
KNI_DeclareHandle(urlObj);
KNI_DeclareHandle(actionObj);
KNI_DeclareHandle(resultObj);
do {
KNI_GetParameterAsObject(1, callerObj);
KNI_GetParameterAsObject(2, urlObj);
KNI_GetParameterAsObject(3, actionObj);
if (PCSL_STRING_OK != midp_jstring_to_pcsl_string(callerObj, &callerId) ||
PCSL_STRING_OK != midp_jstring_to_pcsl_string(urlObj, &url) ||
PCSL_STRING_OK != midp_jstring_to_pcsl_string(actionObj, &action)) {
KNI_ThrowNew(midpOutOfMemoryError,
"RegistryStore_getByURL0 no memory for string arguments");
break;
}
jsr211_handler_by_URL(&callerId, &url, &action, &result);
} while (0);
pcsl_string_free(&action);
pcsl_string_free(&url);
pcsl_string_free(&callerId);
result2string((_JSR211_INTERNAL_RESULT_BUFFER_*)&result, resultObj);
KNI_EndHandlesAndReturnObject(resultObj);
}
示例5: jsr211_cleanHandlerData
/**
* Cleans up all data memebers of given data structure,
* <br>but <code>handler</code> itself is not cleared.
* @param handler pointer on data structure
* <code>JSR211_content_handler</code> to be cleared.
*/
void jsr211_cleanHandlerData(JSR211_content_handler *handler) {
// clean up handler structure
if (pcsl_string_is_null(&(handler->id)) == PCSL_FALSE) {
pcsl_string_free(&(handler->id));
}
if (pcsl_string_is_null(&(handler->class_name)) == PCSL_FALSE) {
pcsl_string_free(&(handler->class_name));
}
if (handler->type_num > 0 && handler->types != NULL) {
free_pcsl_string_list(handler->types, handler->type_num);
}
if (handler->suff_num > 0 && handler->suffixes != NULL) {
free_pcsl_string_list(handler->suffixes, handler->suff_num);
}
if (handler->act_num > 0 && handler->actions != NULL) {
free_pcsl_string_list(handler->actions, handler->act_num);
}
if (handler->locale_num > 0 && handler->locales != NULL) {
free_pcsl_string_list(handler->locales, handler->locale_num);
}
if (handler->act_num > 0 && handler->locale_num > 0 && handler->action_map != NULL) {
free_pcsl_string_list(handler->action_map, handler->act_num * handler->locale_num);
}
if (handler->access_num > 0 && handler->accesses != NULL) {
free_pcsl_string_list(handler->accesses, handler->access_num);
}
}
示例6: OsFile_rename
bool OsFile_rename(const JvmPathChar *from, const JvmPathChar *to) {
const int from_name_len = fn_strlen(from);
const int to_name_len = fn_strlen(to);
pcsl_string pcsl_filename_from = PCSL_STRING_NULL;
pcsl_string pcsl_filename_to = PCSL_STRING_NULL;
GUARANTEE(sizeof(jchar) == sizeof(JvmPathChar), "Types must match");
if (pcsl_string_convert_from_utf16(from,
from_name_len,
&pcsl_filename_from) != PCSL_STRING_OK) {
return -1;
}
if (pcsl_string_convert_from_utf16(to,
to_name_len,
&pcsl_filename_to) != PCSL_STRING_OK) {
return -1;
}
int result = pcsl_file_rename(&pcsl_filename_from, &pcsl_filename_to);
pcsl_string_free(&pcsl_filename_from);
pcsl_string_free(&pcsl_filename_to);
return (result == 0) ? true : false;
}
示例7: Java_javax_microedition_lcdui_ImageItemLFImpl_createNativeResource0
/**
* KNI function that creates new native resource for the current ImageItem.
*
* Class: javax.microedition.lcdui.ImageItemLFImpl
* Java prototype:
* private native int createNativeResource0(int ownerId, String label,
* int layout,
* Image img, String altText,
* int appearanceMode)
*
* INTERFACE (operand stack manipulation):
* parameters: ownerId pointer to the owner's native resource
* label ImageItem's label
* layout ImageItem's layout
* img ImageItem's image
* altText ImageItem's attText
* appearanceMode the appearanceMode of ImageItem
* return pointer to the created native resource
*/
KNIEXPORT KNI_RETURNTYPE_INT
Java_javax_microedition_lcdui_ImageItemLFImpl_createNativeResource0() {
MidpError err = KNI_OK;
MidpDisplayable *ownerPtr;
MidpItem *itemPtr = NULL;
pcsl_string label, altText;
pcsl_string_status rc1,rc2;
unsigned char* imgPtr = NULL;
int appearanceMode, layout;
KNI_StartHandles(3);
KNI_DeclareHandle(labelJString);
KNI_DeclareHandle(image);
KNI_DeclareHandle(altTextJString);
ownerPtr = (MidpDisplayable *)KNI_GetParameterAsInt(1);
KNI_GetParameterAsObject(2, labelJString);
layout = KNI_GetParameterAsInt(3);
KNI_GetParameterAsObject(4, image);
KNI_GetParameterAsObject(5, altTextJString);
if (KNI_IsNullHandle(image) != KNI_TRUE) {
imgPtr = gxp_get_imagedata(image);
}
appearanceMode = KNI_GetParameterAsInt(6);
rc1 = midp_jstring_to_pcsl_string(labelJString, &label);
rc2 = midp_jstring_to_pcsl_string(altTextJString, &altText);
KNI_EndHandles();
/* NULL and empty strings are acceptable. */
if (PCSL_STRING_OK != rc1 || PCSL_STRING_OK != rc2 ) {
err = KNI_ENOMEM;
goto cleanup;
}
itemPtr = MidpNewItem(ownerPtr, MIDP_PLAIN_IMAGE_ITEM_TYPE+appearanceMode);
if (itemPtr == NULL) {
err = KNI_ENOMEM;
goto cleanup;
}
err = lfpport_imageitem_create(itemPtr, ownerPtr, &label, layout,
imgPtr, &altText, appearanceMode);
cleanup:
pcsl_string_free(&altText);
pcsl_string_free(&label);
if (err != KNI_OK) {
MidpDeleteItem(itemPtr);
KNI_ThrowNew(midpOutOfMemoryError, NULL);
}
KNI_ReturnInt(itemPtr);
}
示例8: storageFinalize
/*
* Finalize the storage subsystem.
*/
void
storageFinalize() {
int i;
for (i = 0; i < MAX_STORAGE_NUM; i++) {
pcsl_string_free(&sRoot[i]);
pcsl_string_free(&configRoot[i]);
}
storageInitDone = 0;
pcsl_file_finalize();
}
示例9: midp_suite_read_secure_resource
/**
* Reads named secure resource of the suite with specified suiteId
* from secure persistent storage.
*
* Note that when porting memory for the in/out parameter
* returnValue MUST be allocated using pcsl_mem_malloc().
* The caller is responsible for freeing it.
*
* @param suiteId The suite id used to identify the MIDlet suite
* @param resourceName The name of secure resource to read from storage
* @param returnValue The in/out parameter that will return the
* value part of the requested secure resource
* (NULL is a valid return value)
* @param valueSize The length of the secure resource value
*
* @return one of the error codes:
* <pre>
* ALL_OK, OUT_OF_MEMORY, NOT_FOUND,
* SUITE_CORRUPTED_ERROR, BAD_PARAMS
* </pre>
*/
MIDPError
midp_suite_read_secure_resource(SuiteIdType suiteId,
const pcsl_string* resourceName,
jbyte **returnValue,
jint *valueSize) {
pcsl_string filename = PCSL_STRING_NULL;
char *pszError = NULL;
MIDPError errorCode;
int bytesRead;
int handle;
*returnValue = NULL;
*valueSize = 0;
errorCode = get_secure_resource_file(suiteId, resourceName, &filename);
if (errorCode != ALL_OK) {
pcsl_string_free(&filename);
return errorCode;
}
handle = storage_open(&pszError, &filename, OPEN_READ);
pcsl_string_free(&filename);
if (pszError != NULL) {
storageFreeError(pszError);
return SUITE_CORRUPTED_ERROR;
}
do {
bytesRead = storageRead(&pszError, handle,
(char*)valueSize, sizeof (int));
if (bytesRead != sizeof (int) || *valueSize == 0)
break;
*returnValue = (jbyte*)pcsl_mem_malloc(*valueSize * sizeof (jbyte));
if (*returnValue == NULL) {
errorCode = OUT_OF_MEMORY;
break;
}
bytesRead = storageRead(&pszError, handle, (char*)(*returnValue),
*valueSize * sizeof (jbyte));
if (pszError != NULL || bytesRead != *valueSize) {
errorCode = SUITE_CORRUPTED_ERROR;
pcsl_mem_free(*returnValue);
*returnValue = NULL;
break;
}
} while (0);
storageClose(&pszError, handle);
storageFreeError(pszError);
return errorCode;
}
示例10: check_for_corrupted_suite
/**
* Check if the suite is corrupted
* @param suiteId ID of a suite
*
* @return ALL_OK if the suite is not corrupted,
* SUITE_CORRUPTED_ERROR is suite is corrupted,
* OUT_OF_MEMORY if out of memory,
* IO_ERROR if I/O error
*/
MIDPError
check_for_corrupted_suite(SuiteIdType suiteId) {
pcsl_string filename[NUM_SUITE_FILES];
int arc[NUM_SUITE_FILES];
int i;
StorageIdType storageId;
MIDPError status = ALL_OK; /* Default to no error */
MidletSuiteData *pData = get_suite_data(suiteId);
if (!pData) {
return SUITE_CORRUPTED_ERROR;
}
/* if this suite was already checked, just return "OK" status */
if (pData->isChecked) {
return status;
}
/* get an id of the storage where the suite is located */
status = midp_suite_get_suite_storage(suiteId, &storageId);
if (status != ALL_OK) {
return status;
}
arc[0] = get_suite_filename(suiteId, &INSTALL_INFO_FILENAME, &filename[0]);
arc[1] = get_suite_filename(suiteId, &SETTINGS_FILENAME, &filename[1]);
arc[2] = midp_suite_get_class_path(suiteId, storageId,
KNI_FALSE, &filename[2]);
arc[3] = get_property_file(suiteId, KNI_FALSE, &filename[3]);
for (i = 0; i < NUM_SUITE_FILES; i++) {
if (arc[i] != ALL_OK) {
status = (MIDPError)arc[i];
break;
}
if (!storage_file_exists(&filename[i])) {
/* File does not exist; suite must be corrupted */
status = SUITE_CORRUPTED_ERROR;
break;
}
}
if (status == ALL_OK) {
/* if the suite is not currupted, mark it as "checked" */
pData->isChecked = 1;
}
pcsl_string_free(&filename[0]);
pcsl_string_free(&filename[1]);
pcsl_string_free(&filename[2]);
pcsl_string_free(&filename[3]);
return status;
}
示例11: buildSuiteFilename
static MIDPError buildSuiteFilename(pcsl_string* filenameBase,
const pcsl_string* name, jint extension,
pcsl_string* pFileName) {
pcsl_string returnPath = PCSL_STRING_NULL;
pcsl_string rmsFileName = PCSL_STRING_NULL;
jsize filenameBaseLen = pcsl_string_length(filenameBase);
jsize nameLen = pcsl_string_length(name);
*pFileName = PCSL_STRING_NULL;
if (nameLen > 0) {
const pcsl_string* ext;
jsize extLen;
int fileNameLen;
if (MIDP_RMS_IDX_EXT == extension) {
ext = &IDX_EXTENSION;
extLen = pcsl_string_length(&IDX_EXTENSION);
} else if (MIDP_RMS_DB_EXT == extension) {
ext = &DB_EXTENSION;
extLen = pcsl_string_length(&DB_EXTENSION);
} else {
return BAD_PARAMS;
}
/* performance hint: predict buffer capacity */
fileNameLen = PCSL_STRING_ESCAPED_BUFFER_SIZE(nameLen + extLen);
pcsl_string_predict_size(&rmsFileName, fileNameLen);
if (pcsl_esc_attach_string(name, &rmsFileName) !=
PCSL_STRING_OK ||
pcsl_string_append(&rmsFileName, ext) != PCSL_STRING_OK) {
pcsl_string_free(&rmsFileName);
return OUT_OF_MEMORY;
}
}
/* performance hint: predict buffer capacity */
pcsl_string_predict_size(&returnPath, filenameBaseLen +
pcsl_string_length(&rmsFileName));
if (PCSL_STRING_OK != pcsl_string_append(&returnPath, filenameBase) ||
PCSL_STRING_OK != pcsl_string_append(&returnPath, &rmsFileName)) {
pcsl_string_free(&rmsFileName);
pcsl_string_free(&returnPath);
return OUT_OF_MEMORY;
}
pcsl_string_free(&rmsFileName);
*pFileName = returnPath;
return ALL_OK;
}
示例12: write_file
/**
* Writes the contents of the given buffer into the given file.
*
* Note that if the length of the input buffer is zero or less,
* the file will be truncated.
*
* @param ppszError pointer to character string pointer to accept an error
* @param pFileName file to write
* @param inBuffer buffer with data that will be stored
* @param inBufferLen length of the inBuffer
*
* @return status code (ALL_OK if there was no errors)
*/
MIDPError
write_file(char** ppszError, const pcsl_string* pFileName,
char* inBuffer, long inBufferLen) {
int handle, status = ALL_OK;
char* pszTemp;
pcsl_string tmpFileName;
pcsl_string_status rc;
*ppszError = NULL;
/* get the name of the temporary file */
rc = pcsl_string_cat(pFileName, &TMP_FILE_EXTENSION, &tmpFileName);
if (rc != PCSL_STRING_OK) {
return OUT_OF_MEMORY;
}
/* open the file */
handle = storage_open(ppszError, &tmpFileName, OPEN_READ_WRITE_TRUNCATE);
if (*ppszError != NULL) {
pcsl_string_free(&tmpFileName);
return IO_ERROR;
}
/* write the whole buffer */
if (inBufferLen > 0) {
storageWrite(ppszError, handle, inBuffer, inBufferLen);
}
if (*ppszError != NULL) {
status = IO_ERROR;
}
/* close the file */
storageClose(&pszTemp, handle);
storageFreeError(pszTemp);
if (status == ALL_OK) {
/* rename the temporary file */
storage_rename_file(ppszError, &tmpFileName, pFileName);
if (*ppszError != NULL) {
status = IO_ERROR;
storage_delete_file(&pszTemp, &tmpFileName);
storageFreeError(pszTemp);
}
} else {
storage_delete_file(&pszTemp, &tmpFileName);
storageFreeError(pszTemp);
}
pcsl_string_free(&tmpFileName);
return (MIDPError)status;
}
示例13: get_class_path_impl
/**
* Gets the classpath for the specified MIDlet suite id.
*
* Note that memory for the in/out parameter classPath is
* allocated by the callee. The caller is responsible for
* freeing it using pcsl_mem_free().
*
* @param suiteId The suite id used to identify the MIDlet suite
* @param storageId storage ID, INTERNAL_STORAGE_ID for the internal storage
* @param classPath The in/out parameter that contains returned class path
* @param extension Extension of the file (
*
* @return one of the error codes:
* <pre>
* ALL_OK, OUT_OF_MEMORY
* </pre>
*/
static MIDPError
get_class_path_impl(ComponentType type,
SuiteIdType suiteId,
ComponentIdType componentId,
jint storageId,
pcsl_string * pClassPath,
const pcsl_string * pExtension) {
const pcsl_string* root = storage_get_root(storageId);
pcsl_string path = PCSL_STRING_NULL;
jint suiteIdLen = GET_SUITE_ID_LEN(suiteId);
jint componentIdLen = 0;
#if ENABLE_DYNAMIC_COMPONENTS
if (type == COMPONENT_DYNAMIC) {
componentIdLen = GET_COMPONENT_ID_LEN(componentId);
}
#else
(void)type;
(void)componentId;
#endif
*pClassPath = PCSL_STRING_NULL;
/* performance hint: predict buffer capacity */
pcsl_string_predict_size(&path, pcsl_string_length(root)
+ suiteIdLen + componentIdLen +
+ pcsl_string_length(pExtension));
if (PCSL_STRING_OK != pcsl_string_append(&path, root) ||
PCSL_STRING_OK != pcsl_string_append(&path,
midp_suiteid2pcsl_string(suiteId))) {
pcsl_string_free(&path);
return OUT_OF_MEMORY;
}
#if ENABLE_DYNAMIC_COMPONENTS
if (type == COMPONENT_DYNAMIC) {
if (PCSL_STRING_OK != pcsl_string_append(&path,
midp_componentid2pcsl_string(componentId))) {
pcsl_string_free(&path);
return OUT_OF_MEMORY;
}
}
#endif
if (PCSL_STRING_OK != pcsl_string_append(&path, pExtension)) {
pcsl_string_free(&path);
return OUT_OF_MEMORY;
}
*pClassPath = path;
return ALL_OK;
}
示例14: midpIterateJarEntries
int
midpIterateJarEntries(void *handle, filterFuncT *filter, actionFuncT *action) {
MidpJarInfo *pJarInfo = (MidpJarInfo*)handle;
JarEntryInfo entryInfo;
pcsl_string entryName;
unsigned char *nameBuf;
int status = 1;
pcsl_string_status res;
entryInfo = getFirstJarEntryInfo(&pJarInfo->fileObj, &pJarInfo->jarInfo);
while (entryInfo.status == 0) {
nameBuf = (unsigned char*) midpMalloc(entryInfo.nameLen);
if (nameBuf == NULL) {
status = MIDP_JAR_OUT_OF_MEM_ERROR;
break;
}
entryInfo.status = getJarEntryName(&pJarInfo->fileObj, &entryInfo, nameBuf);
if (entryInfo.status != 0) {
status = MIDP_JAR_CORRUPT_ERROR;
midpFree(nameBuf);
break;
}
res = pcsl_string_convert_from_utf8((jbyte*)nameBuf, entryInfo.nameLen,
&entryName);
midpFree(nameBuf);
if (PCSL_STRING_OK != res) {
status = MIDP_JAR_OUT_OF_MEM_ERROR;
break;
}
if ((*filter)(&entryName)) {
/* name match: call action */
if (!(*action)(&entryName)) {
status = 0;
pcsl_string_free(&entryName);
break;
}
}
pcsl_string_free(&entryName);
entryInfo = getNextJarEntryInfo(&pJarInfo->fileObj, &pJarInfo->jarInfo,
&entryInfo);
}
return status;
}
示例15: midp_suite_get_cached_resource_filename
/**
* Gets location of the cached resource with specified name
* for the suite with the specified suiteId.
*
* Note that when porting memory for the in/out parameter
* filename MUST be allocated using pcsl_mem_malloc().
* The caller is responsible for freeing the memory associated
* with filename parameter.
*
* @param suiteId The application suite ID
* @param storageId storage ID, INTERNAL_STORAGE_ID for the internal storage
* @param pResourceName Name of the cached resource
* @param pFileName The in/out parameter that contains returned filename
* @return error code that should be one of the following:
* <pre>
* ALL_OK, OUT_OF_MEMORY, NOT_FOUND,
* SUITE_CORRUPTED_ERROR, BAD_PARAMS
* </pre>
*/
MIDPError
midp_suite_get_cached_resource_filename(SuiteIdType suiteId,
StorageIdType storageId,
const pcsl_string * pResourceName,
pcsl_string * pFileName) {
const pcsl_string* root = storage_get_root(storageId);
pcsl_string returnPath = PCSL_STRING_NULL;
pcsl_string resourceFileName = PCSL_STRING_NULL;
jint suiteIdLen = GET_SUITE_ID_LEN(suiteId);
jsize resourceNameLen = pcsl_string_length(pResourceName);
*pFileName = PCSL_STRING_NULL;
if (resourceNameLen > 0) {
/* performance hint: predict buffer capacity */
int fileNameLen = PCSL_STRING_ESCAPED_BUFFER_SIZE(
resourceNameLen + pcsl_string_length(&TMP_EXT));
pcsl_string_predict_size(&resourceFileName, fileNameLen);
if ( /* Convert any slashes */
pcsl_esc_attach_string(pResourceName,
&resourceFileName) != PCSL_STRING_OK ||
/* Add the extension */
pcsl_string_append(&resourceFileName, &TMP_EXT) !=
PCSL_STRING_OK) {
pcsl_string_free(&resourceFileName);
return OUT_OF_MEMORY;
}
}
/* performance hint: predict buffer capacity */
pcsl_string_predict_size(&returnPath, pcsl_string_length(root) +
suiteIdLen + pcsl_string_length(&resourceFileName));
if (PCSL_STRING_OK != pcsl_string_append(&returnPath, root) ||
PCSL_STRING_OK != pcsl_string_append(&returnPath,
midp_suiteid2pcsl_string(suiteId)) ||
PCSL_STRING_OK != pcsl_string_append(&returnPath,
&resourceFileName)) {
pcsl_string_free(&resourceFileName);
pcsl_string_free(&returnPath);
return OUT_OF_MEMORY;
}
pcsl_string_free(&resourceFileName);
*pFileName = returnPath;
return ALL_OK;
}