这篇教程C++ uprv_malloc函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中uprv_malloc函数的典型用法代码示例。如果您正苦于以下问题:C++ uprv_malloc函数的具体用法?C++ uprv_malloc怎么用?C++ uprv_malloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了uprv_malloc函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: uprv_freevoidStringEnumeration::ensureCharsCapacity(int32_t capacity, UErrorCode &status) { if(U_SUCCESS(status) && capacity>charsCapacity) { if(capacity<(charsCapacity+charsCapacity/2)) { // avoid allocation thrashing capacity=charsCapacity+charsCapacity/2; } if(chars!=charsBuffer) { uprv_free(chars); } chars=(char *)uprv_malloc(capacity); if(chars==NULL) { chars=charsBuffer; charsCapacity=sizeof(charsBuffer); status=U_MEMORY_ALLOCATION_ERROR; } else { charsCapacity=capacity; } }}
开发者ID:Abocer,项目名称:android-4.2_r1,代码行数:20,
示例2: ulist_createEmptyListU_CAPI UList *U_EXPORT2 ulist_createEmptyList(UErrorCode *status) { UList *newList = NULL; if (U_FAILURE(*status)) { return NULL; } newList = (UList *)uprv_malloc(sizeof(UList)); if (newList == NULL) { *status = U_MEMORY_ALLOCATION_ERROR; return NULL; } newList->curr = NULL; newList->head = NULL; newList->tail = NULL; newList->size = 0; return newList;}
开发者ID:MoonchildProductions,项目名称:Pale-Moon,代码行数:20,
示例3: ucm_openU_CAPI UCMFile * U_EXPORT2ucm_open() { UCMFile *ucm=(UCMFile *)uprv_malloc(sizeof(UCMFile)); if(ucm==NULL) { fprintf(stderr, "ucm error: unable to allocate a UCMFile/n"); exit(U_MEMORY_ALLOCATION_ERROR); } memset(ucm, 0, sizeof(UCMFile)); ucm->base=ucm_openTable(); ucm->ext=ucm_openTable(); ucm->states.stateFlags[0]=MBCS_STATE_FLAG_DIRECT; ucm->states.conversionType=UCNV_UNSUPPORTED_CONVERTER; ucm->states.outputType=-1; ucm->states.minCharLength=ucm->states.maxCharLength=1; return ucm;}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:20,
示例4: pathToFullPathstatic char *pathToFullPath(const char *path, const char *source) { int32_t length; int32_t newLength; char *fullPath; int32_t n; length = (uint32_t)(uprv_strlen(path) + 1); newLength = (length + 1 + (int32_t)uprv_strlen(source)); fullPath = uprv_malloc(newLength); if(source != NULL) { uprv_strcpy(fullPath, source); uprv_strcat(fullPath, U_FILE_SEP_STRING); } else { fullPath[0] = 0; } n = (int32_t)uprv_strlen(fullPath); fullPath[n] = 0; /* Suppress compiler warning for unused variable n */ /* when conditional code below is not compiled. */ uprv_strcat(fullPath, path);#if (U_FILE_ALT_SEP_CHAR != U_TREE_ENTRY_SEP_CHAR)#if (U_FILE_ALT_SEP_CHAR != U_FILE_SEP_CHAR) /* replace tree separator (such as '/') with file sep char (such as ':' or '//') */ for(;fullPath[n];n++) { if(fullPath[n] == U_FILE_ALT_SEP_CHAR) { fullPath[n] = U_FILE_SEP_CHAR; } }#endif#endif#if (U_FILE_SEP_CHAR != U_TREE_ENTRY_SEP_CHAR) /* replace tree separator (such as '/') with file sep char (such as ':' or '//') */ for(;fullPath[n];n++) { if(fullPath[n] == U_TREE_ENTRY_SEP_CHAR) { fullPath[n] = U_FILE_SEP_CHAR; } }#endif return fullPath;}
开发者ID:00zhengfu00,项目名称:third_party,代码行数:41,
示例5: ucmp8_expandU_CAPI void U_EXPORT2ucmp8_expand(CompactByteArray* this_obj) { /* can optimize later. * if we have to expand, then walk through the blocks instead of using Get * this code unpacks the array by copying the blocks to the normalized position. * Example: Compressed * INDEX# 0 1 2 3 4 * INDEX 0 4 1 8 2 ... * ARRAY abcdeabazyabc... * turns into * Example: Expanded * INDEX# 0 1 2 3 4 * INDEX 0 4 8 12 16 ... * ARRAY abcdeababcedzyabcdea... */ int32_t i; if (this_obj->fCompact) { int8_t* tempArray; tempArray = (int8_t*) uprv_malloc(sizeof(int8_t) * UCMP8_kUnicodeCount); if (!tempArray) { this_obj->fBogus = TRUE; return; } for (i = 0; i < UCMP8_kUnicodeCount; ++i) { tempArray[i] = ucmp8_get(this_obj,(UChar)i); /* HSYS : How expand?*/ } for (i = 0; i < UCMP8_kIndexCount; ++i) { this_obj->fIndex[i] = (uint16_t)(i<< UCMP8_kBlockShift); } uprv_free(this_obj->fArray); this_obj->fArray = tempArray; this_obj->fCompact = FALSE; this_obj->fAlias = FALSE; }}
开发者ID:gitpan,项目名称:ponie,代码行数:41,
示例6: _CompoundTextOpenstatic void_CompoundTextOpen(UConverter *cnv, UConverterLoadArgs *pArgs, UErrorCode *errorCode){ cnv->extraInfo = uprv_malloc (sizeof (UConverterDataCompoundText)); if (cnv->extraInfo != NULL) { UConverterDataCompoundText *myConverterData = (UConverterDataCompoundText *) cnv->extraInfo; UConverterNamePieces stackPieces; UConverterLoadArgs stackArgs={ (int32_t)sizeof(UConverterLoadArgs) }; myConverterData->myConverterArray[COMPOUND_TEXT_SINGLE_0] = NULL; myConverterData->myConverterArray[COMPOUND_TEXT_SINGLE_1] = ucnv_loadSharedData("icu-internal-compound-s1", &stackPieces, &stackArgs, errorCode); myConverterData->myConverterArray[COMPOUND_TEXT_SINGLE_2] = ucnv_loadSharedData("icu-internal-compound-s2", &stackPieces, &stackArgs, errorCode); myConverterData->myConverterArray[COMPOUND_TEXT_SINGLE_3] = ucnv_loadSharedData("icu-internal-compound-s3", &stackPieces, &stackArgs, errorCode); myConverterData->myConverterArray[COMPOUND_TEXT_DOUBLE_1] = ucnv_loadSharedData("icu-internal-compound-d1", &stackPieces, &stackArgs, errorCode); myConverterData->myConverterArray[COMPOUND_TEXT_DOUBLE_2] = ucnv_loadSharedData("icu-internal-compound-d2", &stackPieces, &stackArgs, errorCode); myConverterData->myConverterArray[COMPOUND_TEXT_DOUBLE_3] = ucnv_loadSharedData("icu-internal-compound-d3", &stackPieces, &stackArgs, errorCode); myConverterData->myConverterArray[COMPOUND_TEXT_DOUBLE_4] = ucnv_loadSharedData("icu-internal-compound-d4", &stackPieces, &stackArgs, errorCode); myConverterData->myConverterArray[COMPOUND_TEXT_DOUBLE_5] = ucnv_loadSharedData("icu-internal-compound-d5", &stackPieces, &stackArgs, errorCode); myConverterData->myConverterArray[COMPOUND_TEXT_DOUBLE_6] = ucnv_loadSharedData("icu-internal-compound-d6", &stackPieces, &stackArgs, errorCode); myConverterData->myConverterArray[COMPOUND_TEXT_DOUBLE_7] = ucnv_loadSharedData("icu-internal-compound-d7", &stackPieces, &stackArgs, errorCode); myConverterData->myConverterArray[COMPOUND_TEXT_TRIPLE_DOUBLE] = ucnv_loadSharedData("icu-internal-compound-t", &stackPieces, &stackArgs, errorCode); myConverterData->myConverterArray[IBM_915] = ucnv_loadSharedData("ibm-915_P100-1995", &stackPieces, &stackArgs, errorCode); myConverterData->myConverterArray[IBM_916] = ucnv_loadSharedData("ibm-916_P100-1995", &stackPieces, &stackArgs, errorCode); myConverterData->myConverterArray[IBM_914] = ucnv_loadSharedData("ibm-914_P100-1995", &stackPieces, &stackArgs, errorCode); myConverterData->myConverterArray[IBM_874] = ucnv_loadSharedData("ibm-874_P100-1995", &stackPieces, &stackArgs, errorCode); myConverterData->myConverterArray[IBM_912] = ucnv_loadSharedData("ibm-912_P100-1995", &stackPieces, &stackArgs, errorCode); myConverterData->myConverterArray[IBM_913] = ucnv_loadSharedData("ibm-913_P100-2000", &stackPieces, &stackArgs, errorCode); myConverterData->myConverterArray[ISO_8859_14] = ucnv_loadSharedData("iso-8859_14-1998", &stackPieces, &stackArgs, errorCode); myConverterData->myConverterArray[IBM_923] = ucnv_loadSharedData("ibm-923_P100-1998", &stackPieces, &stackArgs, errorCode); if (U_FAILURE(*errorCode) || pArgs->onlyTestIsLoadable) { _CompoundTextClose(cnv); return; } myConverterData->state = (COMPOUND_TEXT_CONVERTERS)0; } else { *errorCode = U_MEMORY_ALLOCATION_ERROR; }}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:41,
示例7: ures_openvoid RelativeDateFormat::loadDates(UErrorCode &status) { UResourceBundle *rb = ures_open(NULL, fLocale.getBaseName(), &status); LocalUResourceBundlePointer dateTimePatterns( ures_getByKeyWithFallback(rb, "calendar/gregorian/DateTimePatterns", (UResourceBundle*)NULL, &status)); if(U_SUCCESS(status)) { int32_t patternsSize = ures_getSize(dateTimePatterns.getAlias()); if (patternsSize > kDateTime) { int32_t resStrLen = 0; int32_t glueIndex = kDateTime; if (patternsSize >= (kDateTimeOffset + kShort + 1)) { int32_t offsetIncrement = (fDateStyle & ~kRelative); // Remove relative bit. if (offsetIncrement >= (int32_t)kFull && offsetIncrement <= (int32_t)kShortRelative) { glueIndex = kDateTimeOffset + offsetIncrement; } } const UChar *resStr = ures_getStringByIndex(dateTimePatterns.getAlias(), glueIndex, &resStrLen, &status); if (U_SUCCESS(status) && resStrLen >= patItem1Len && u_strncmp(resStr,patItem1,patItem1Len)==0) { fCombinedHasDateAtStart = TRUE; } fCombinedFormat = new SimpleFormatter(UnicodeString(TRUE, resStr, resStrLen), 2, 2, status); } } // Data loading for relative names, e.g., "yesterday", "today", "tomorrow". fDatesLen = UDAT_DIRECTION_COUNT; // Maximum defined by data. fDates = (URelativeString*) uprv_malloc(sizeof(fDates[0])*fDatesLen); RelDateFmtDataSink sink(fDates, fDatesLen); ures_getAllItemsWithFallback(rb, "fields/day/relative", sink, status); ures_close(rb); if(U_FAILURE(status)) { fDatesLen=0; return; }}
开发者ID:DavidCai1993,项目名称:node,代码行数:41,
示例8: verifyResult/* closes res but does not free resultsManually */static void verifyResult(UEnumeration* res, const UBool *resultsManually) { UBool* resultsFromSystem = (UBool*) uprv_malloc(gCountAvailable * sizeof(UBool)); const char* name; UErrorCode status = U_ZERO_ERROR; int32_t i; /* fill the bool for the selector results! */ uprv_memset(resultsFromSystem, 0, gCountAvailable); while ((name = uenum_next(res,NULL, &status)) != NULL) { resultsFromSystem[findIndex(name)] = TRUE; } for(i = 0 ; i < gCountAvailable; i++) { if(resultsManually[i] != resultsFromSystem[i]) { log_err("failure in converter selector/n" "converter %s had conflicting results -- manual: %d, system %d/n", gAvailableNames[i], resultsManually[i], resultsFromSystem[i]); } } uprv_free(resultsFromSystem); uenum_close(res);}
开发者ID:winlibs,项目名称:icu4c,代码行数:22,
示例9: unorm_normalizeNFDBuffer::NFDBuffer(const UChar *text, int32_t length, UErrorCode &status) { fNormalizedText = NULL; fNormalizedTextLength = 0; fOriginalText = text; if (U_FAILURE(status)) { return; } fNormalizedText = fSmallBuf; fNormalizedTextLength = unorm_normalize( text, length, UNORM_NFD, 0, fNormalizedText, USPOOF_STACK_BUFFER_SIZE, &status); if (status == U_BUFFER_OVERFLOW_ERROR) { status = U_ZERO_ERROR; fNormalizedText = (UChar *)uprv_malloc((fNormalizedTextLength+1)*sizeof(UChar)); if (fNormalizedText == NULL) { status = U_MEMORY_ALLOCATION_ERROR; } else { fNormalizedTextLength = unorm_normalize(text, length, UNORM_NFD, 0, fNormalizedText, fNormalizedTextLength+1, &status); } }}
开发者ID:Abocer,项目名称:android-4.2_r1,代码行数:21,
示例10: uspoof_getSkeleton/* A convenience wrapper around the public uspoof_getSkeleton that handles * allocating a larger buffer than provided if the original is too small. */static UChar *getSkeleton(const USpoofChecker *sc, uint32_t type, const UChar *s, int32_t inputLength, UChar *dest, int32_t destCapacity, int32_t *outputLength, UErrorCode *status) { int32_t requiredCapacity = 0; UChar *buf = dest; if (U_FAILURE(*status)) { return NULL; } requiredCapacity = uspoof_getSkeleton(sc, type, s, inputLength, dest, destCapacity, status); if (*status == U_BUFFER_OVERFLOW_ERROR) { buf = static_cast<UChar *>(uprv_malloc(requiredCapacity * sizeof(UChar))); if (buf == NULL) { *status = U_MEMORY_ALLOCATION_ERROR; return NULL; } *status = U_ZERO_ERROR; uspoof_getSkeleton(sc, type, s, inputLength, buf, requiredCapacity, status); } *outputLength = requiredCapacity; return buf;}
开发者ID:BrunoReX,项目名称:palemoon,代码行数:24,
示例11: uprv_free/** * Assignment operator. */CompoundTransliterator& CompoundTransliterator::operator=( const CompoundTransliterator& t){ Transliterator::operator=(t); int32_t i = 0; UBool failed = FALSE; if (trans != NULL) { for (i=0; i<count; ++i) { delete trans[i]; trans[i] = 0; } } if (t.count > count) { if (trans != NULL) { uprv_free(trans); } trans = (Transliterator **)uprv_malloc(t.count * sizeof(Transliterator *)); } count = t.count; if (trans != NULL) { for (i=0; i<count; ++i) { trans[i] = t.trans[i]->clone(); if (trans[i] == NULL) { failed = TRUE; break; } } } // if memory allocation failed delete backwards trans array if (failed && i > 0) { int32_t n; for (n = i-1; n >= 0; n--) { uprv_free(trans[n]); trans[n] = NULL; } } numAnonymousRBTs = t.numAnonymousRBTs; return *this;}
开发者ID:119120119,项目名称:node,代码行数:43,
示例12: uprv_mapFile UBool uprv_mapFile(UDataMemory *pData, const char *path) { FILE *file; int32_t fileLength; void *p; UDataMemory_init(pData); /* Clear the output struct. */ /* open the input file */ file=fopen(path, "rb"); if(file==NULL) { return FALSE; } /* get the file length */ fileLength=umap_fsize(file); if(ferror(file) || fileLength<=20) { fclose(file); return FALSE; } /* allocate the memory to hold the file data */ p=uprv_malloc(fileLength); if(p==NULL) { fclose(file); return FALSE; } /* read the file */ if(fileLength!=fread(p, 1, fileLength, file)) { uprv_free(p); fclose(file); return FALSE; } fclose(file); pData->map=p; pData->pHeader=(const DataHeader *)p; pData->mapAddr=p; return TRUE; }
开发者ID:mathtexts,项目名称:uimacpp,代码行数:40,
示例13: utrans_openIDsU_CAPI UEnumeration * U_EXPORT2utrans_openIDs(UErrorCode * pErrorCode){ UTransEnumeration * ute; if (pErrorCode == NULL || U_FAILURE(*pErrorCode)) { return NULL; } ute = (UTransEnumeration *)uprv_malloc(sizeof(UTransEnumeration)); if (ute == NULL) { *pErrorCode = U_MEMORY_ALLOCATION_ERROR; return NULL; } ute->uenum = utransEnumeration; ute->index = 0; ute->count = Transliterator::countAvailableIDs(); return (UEnumeration *)ute;}
开发者ID:Botyto,项目名称:Core,代码行数:22,
示例14: utm_openU_CAPI UToolMemory * U_EXPORT2utm_open(const char *name, int32_t initialCapacity, int32_t maxCapacity, int32_t size) { UToolMemory *mem; if(maxCapacity<initialCapacity) { maxCapacity=initialCapacity; } mem=(UToolMemory *)uprv_malloc(sizeof(UToolMemory)+initialCapacity*size); if(mem==NULL) { fprintf(stderr, "error: %s - out of memory/n", name); exit(U_MEMORY_ALLOCATION_ERROR); } mem->array=mem->staticArray; uprv_strcpy(mem->name, name); mem->capacity=initialCapacity; mem->maxCapacity=maxCapacity; mem->size=size; mem->index=0; return mem;}
开发者ID:andrewleech,项目名称:firebird,代码行数:22,
示例15: bufferU_NAMESPACE_BEGINuint8_t *RuleBasedCollator::cloneRuleData(int32_t &length, UErrorCode &errorCode) const { if(U_FAILURE(errorCode)) { return NULL; } LocalMemory<uint8_t> buffer((uint8_t *)uprv_malloc(20000)); if(buffer.isNull()) { errorCode = U_MEMORY_ALLOCATION_ERROR; return NULL; } length = cloneBinary(buffer.getAlias(), 20000, errorCode); if(errorCode == U_BUFFER_OVERFLOW_ERROR) { if(buffer.allocateInsteadAndCopy(length, 0) == NULL) { errorCode = U_MEMORY_ALLOCATION_ERROR; return NULL; } errorCode = U_ZERO_ERROR; length = cloneBinary(buffer.getAlias(), length, errorCode); } if(U_FAILURE(errorCode)) { return NULL; } return buffer.orphan();}
开发者ID:icu-project,项目名称:icu4c,代码行数:22,
示例16: u_growBufferFromStaticU_CAPI UBool /* U_CALLCONV U_EXPORT2 */u_growBufferFromStatic(void* context, UChar** pBuffer, int32_t* pCapacity, int32_t reqCapacity, int32_t length) { UChar* newBuffer = (UChar*) uprv_malloc(reqCapacity * U_SIZEOF_UCHAR); if (newBuffer != NULL) { if (length > 0) { uprv_memcpy(newBuffer, *pBuffer, length * U_SIZEOF_UCHAR); } *pCapacity = reqCapacity; } else { *pCapacity = 0; } /* release the old pBuffer if it was not statically allocated */ if (*pBuffer != (UChar*) context) { uprv_free(*pBuffer); } *pBuffer = newBuffer; return (UBool) (newBuffer != NULL);}
开发者ID:mathtexts,项目名称:uimacpp,代码行数:22,
示例17: pathToFullPathstatic char * pathToFullPath(const char *path) { int32_t length; int32_t newLength; char *fullPath; int32_t n; length = (uint32_t)(uprv_strlen(path) + 1); newLength = (length + 1 + (int32_t)uprv_strlen(options[10].value)); fullPath = uprv_malloc(newLength); if(options[10].doesOccur) { uprv_strcpy(fullPath, options[10].value); uprv_strcat(fullPath, U_FILE_SEP_STRING); } else { fullPath[0] = 0; } n = (int32_t)uprv_strlen(fullPath); uprv_strcat(fullPath, path);#if (U_FILE_ALT_SEP_CHAR != U_TREE_ENTRY_SEP_CHAR)#if (U_FILE_ALT_SEP_CHAR != U_FILE_SEP_CHAR) /* replace tree separator (such as '/') with file sep char (such as ':' or '//') */ for(;fullPath[n];n++) { if(fullPath[n] == U_FILE_ALT_SEP_CHAR) { fullPath[n] = U_FILE_SEP_CHAR; } }#endif#endif#if (U_FILE_SEP_CHAR != U_TREE_ENTRY_SEP_CHAR) /* replace tree separator (such as '/') with file sep char (such as ':' or '//') */ for(;fullPath[n];n++) { if(fullPath[n] == U_TREE_ENTRY_SEP_CHAR) { fullPath[n] = U_FILE_SEP_CHAR; } }#endif return fullPath;}
开发者ID:Katarzynasrom,项目名称:patch-hosting-for-android-x86-support,代码行数:39,
示例18: getAvailableNamesstatic UBoolgetAvailableNames() { int32_t i; if (gAvailableNames != NULL) { return TRUE; } gCountAvailable = ucnv_countAvailable(); if (gCountAvailable == 0) { log_data_err("No converters available./n"); return FALSE; } gAvailableNames = (const char **)uprv_malloc(gCountAvailable * sizeof(const char *)); if (gAvailableNames == NULL) { log_err("unable to allocate memory for %ld available converter names/n", (long)gCountAvailable); return FALSE; } for (i = 0; i < gCountAvailable; ++i) { gAvailableNames[i] = ucnv_getAvailableName(i); } return TRUE;}
开发者ID:winlibs,项目名称:icu4c,代码行数:22,
示例19: _uhash_allocate/** * Allocate internal data array of a size determined by the given * prime index. If the index is out of range it is pinned into range. * If the allocation fails the status is set to * U_MEMORY_ALLOCATION_ERROR and all array storage is freed. In * either case the previous array pointer is overwritten. * * Caller must ensure primeIndex is in range 0..PRIME_LENGTH-1. */static void_uhash_allocate(UHashtable *hash, int32_t primeIndex, UErrorCode *status) { UHashElement *p, *limit; UHashTok emptytok; if (U_FAILURE(*status)) return; U_ASSERT(primeIndex >= 0 && primeIndex < PRIMES_LENGTH); hash->primeIndex = primeIndex; hash->length = PRIMES[primeIndex]; p = hash->elements = (UHashElement*) uprv_malloc(sizeof(UHashElement) * hash->length); if (hash->elements == NULL) { *status = U_MEMORY_ALLOCATION_ERROR; return; } emptytok.pointer = NULL; /* Only one of these two is needed */ emptytok.integer = 0; /* but we don't know which one. */ limit = p + hash->length; while (p < limit) { p->key = emptytok; p->value = emptytok; p->hashcode = HASH_EMPTY; ++p; } hash->count = 0; hash->lowWaterMark = (int32_t)(hash->length * hash->lowWaterRatio); hash->highWaterMark = (int32_t)(hash->length * hash->highWaterRatio);}
开发者ID:S0043640wipro,项目名称:RiCRiPInt,代码行数:47,
示例20: utm_hasCapacitystatic UBoolutm_hasCapacity(UToolMemory *mem, int32_t capacity) { if(mem->capacity<capacity) { int32_t newCapacity; if(mem->maxCapacity<capacity) { fprintf(stderr, "error: %s - trying to use more than maxCapacity=%ld units/n", mem->name, (long)mem->maxCapacity); exit(U_MEMORY_ALLOCATION_ERROR); } /* try to allocate a larger array */ if(capacity>=2*mem->capacity) { newCapacity=capacity; } else if(mem->capacity<=mem->maxCapacity/3) { newCapacity=2*mem->capacity; } else { newCapacity=mem->maxCapacity; } if(mem->array==mem->staticArray) { mem->array=uprv_malloc(newCapacity*mem->size); if(mem->array!=NULL) { uprv_memcpy(mem->array, mem->staticArray, mem->idx*mem->size); } } else { mem->array=uprv_realloc(mem->array, newCapacity*mem->size); } if(mem->array==NULL) { fprintf(stderr, "error: %s - out of memory/n", mem->name); exit(U_MEMORY_ALLOCATION_ERROR); } mem->capacity=newCapacity; } return TRUE;}
开发者ID:00zhengfu00,项目名称:third_party,代码行数:38,
示例21: TZEnumeration TZEnumeration(const char* country) : map(NULL), len(0), pos(0) { if (!getOlsonMeta()) { return; } char key[] = {0, 0, 0, 0,0, 0, 0,0, 0, 0,0}; // e.g., "US", or "Default" for no country if (country) { uprv_strncat(key, country, 2); } else { uprv_strcpy(key, kDEFAULT); } UErrorCode ec = U_ZERO_ERROR; UResourceBundle *top = ures_openDirect(0, kZONEINFO, &ec); top = ures_getByKey(top, kREGIONS, top, &ec); // dereference 'Regions' section if (U_SUCCESS(ec)) { UResourceBundle res; ures_initStackObject(&res); ures_getByKey(top, key, &res, &ec); // The list of zones is a list of integers, from 0..n-1, // where n is the total number of system zones. const int32_t* v = ures_getIntVector(&res, &len, &ec); if (U_SUCCESS(ec)) { U_ASSERT(len > 0); map = (int32_t*)uprv_malloc(sizeof(int32_t) * len); if (map != 0) { for (uint16_t i=0; i<len; ++i) { U_ASSERT(v[i] >= 0 && v[i] < OLSON_ZONE_COUNT); map[i] = v[i]; } } } else { U_DEBUG_TZ_MSG(("Failed to load tz for region %s: %s/n", country, u_errorName(ec))); } ures_close(&res); } ures_close(top); }
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:38,
示例22: UObjectCollationKey::CollationKey(const CollationKey& other): UObject(other), fBogus(FALSE), fCount(other.fCount), fCapacity(other.fCapacity), fHashCode(other.fHashCode), fBytes(NULL){ if (other.fBogus) { setToBogus(); return; } fBytes = (uint8_t *)uprv_malloc(fCapacity); if (fBytes == NULL) { setToBogus(); return; } uprv_memcpy(fBytes, other.fBytes, other.fCount); if(fCapacity>fCount) { uprv_memset(fBytes+fCount, 0, fCapacity-fCount); }}
开发者ID:0omega,项目名称:platform_external_icu4c,代码行数:23,
示例23: insertionSortstatic voidinsertionSort(char *array, int32_t length, int32_t itemSize, UComparator *cmp, const void *context, UErrorCode *pErrorCode) { UAlignedMemory v[STACK_ITEM_SIZE/sizeof(UAlignedMemory)+1]; void *pv; /* allocate an intermediate item variable (v) */ if(itemSize<=STACK_ITEM_SIZE) { pv=v; } else { pv=uprv_malloc(itemSize); if(pv==NULL) { *pErrorCode=U_MEMORY_ALLOCATION_ERROR; return; } } doInsertionSort(array, 0, length, itemSize, cmp, context, pv); if(pv!=v) { uprv_free(pv); }}
开发者ID:LittoCats,项目名称:OT_4010D,代码行数:23,
示例24: _getBuffer/* Return a pointer to the baseContext buffer, possibly allocating or reallocating it if at least 'capacity' bytes are not available. */static void* _getBuffer(UEnumeration* en, int32_t capacity) { if (en->baseContext != NULL) { if (((_UEnumBuffer*) en->baseContext)->len < capacity) { capacity += PAD; en->baseContext = uprv_realloc(en->baseContext, sizeof(int32_t) + capacity); if (en->baseContext == NULL) { return NULL; } ((_UEnumBuffer*) en->baseContext)->len = capacity; } } else { capacity += PAD; en->baseContext = uprv_malloc(sizeof(int32_t) + capacity); if (en->baseContext == NULL) { return NULL; } ((_UEnumBuffer*) en->baseContext)->len = capacity; } return (void*) & ((_UEnumBuffer*) en->baseContext)->data;}
开发者ID:MoonchildProductions,项目名称:Pale-Moon,代码行数:25,
示例25: uprv_malloc/** * Allocate subformats[] to at least the given capacity and return * TRUE if successful. If not, leave subformats[] unchanged. * * If subformats is NULL, allocate it. If it is not NULL, enlarge it * if necessary to be at least as large as specified. */UBool MessageFormat::allocateSubformats(int32_t capacity) { if (subformats == NULL) { subformats = (Subformat*) uprv_malloc(sizeof(*subformats) * capacity); subformatCapacity = capacity; subformatCount = 0; if (subformats == NULL) { subformatCapacity = 0; return FALSE; } } else if (subformatCapacity < capacity) { if (capacity < 2*subformatCapacity) { capacity = 2*subformatCapacity; } Subformat* a = (Subformat*) uprv_realloc(subformats, sizeof(*subformats) * capacity); if (a == NULL) { return FALSE; // request failed } subformats = a; subformatCapacity = capacity; } return TRUE;}
开发者ID:mason105,项目名称:red5cpp,代码行数:30,
示例26: u_growAnyBufferFromStaticstatic U_INLINE UBool u_growAnyBufferFromStatic(void *context, void **pBuffer, int32_t *pCapacity, int32_t reqCapacity, int32_t length, int32_t size) { void *newBuffer=uprv_malloc(reqCapacity*size); if(newBuffer!=NULL) { if(length>0) { uprv_memcpy(newBuffer, *pBuffer, length*size); } *pCapacity=reqCapacity; } else { *pCapacity=0; } /* release the old pBuffer if it was not statically allocated */ if(*pBuffer!=(void *)context) { uprv_free(*pBuffer); } *pBuffer=newBuffer; return (UBool)(newBuffer!=NULL);}
开发者ID:Andproject,项目名称:platform_external_icu4c,代码行数:23,
示例27: uprv_reallocU_CAPI void * U_EXPORT2uprv_realloc(void * buffer, size_t size) {#if U_DEBUG && defined(UPRV_MALLOC_COUNT) putchar('~'); fflush(stdout);#endif if (buffer == zeroMem) { return uprv_malloc(size); } else if (size == 0) { if (pFree) { (*pFree)(pContext, buffer); } else { uprv_default_free(buffer); } return (void *)zeroMem; } else { if (pRealloc) { return (*pRealloc)(pContext, buffer, size); } else { return uprv_default_realloc(buffer, size); } }}
开发者ID:AaronNGray,项目名称:texlive-libs,代码行数:23,
示例28: uprv_freeCollationKey&CollationKey::ensureCapacity(int32_t newSize){ if (fCapacity < newSize) { uprv_free(fBytes); fBytes = (uint8_t *)uprv_malloc(newSize); if (fBytes == NULL) { return setToBogus(); } uprv_memset(fBytes, 0, fCapacity); fCapacity = newSize; } fBogus = FALSE; fCount = newSize; fHashCode = kInvalidHashCode; return *this;}
开发者ID:0omega,项目名称:platform_external_icu4c,代码行数:24,
示例29: quickSortstatic voidquickSort(char *array, int32_t length, int32_t itemSize, UComparator *cmp, const void *context, UErrorCode *pErrorCode) { UAlignedMemory xw[(2*STACK_ITEM_SIZE)/sizeof(UAlignedMemory)+1]; void *p; /* allocate two intermediate item variables (x and w) */ if(itemSize<=STACK_ITEM_SIZE) { p=xw; } else { p=uprv_malloc(2*itemSize); if(p==NULL) { *pErrorCode=U_MEMORY_ALLOCATION_ERROR; return; } } subQuickSort(array, 0, length, itemSize, cmp, context, p, (char *)p+itemSize); if(p!=xw) { uprv_free(p); }}
开发者ID:LittoCats,项目名称:OT_4010D,代码行数:24,
示例30: u_vfprintfU_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */u_vfprintf(UFILE * f, const char * patternSpecification, va_list ap){ int32_t count; UChar * pattern; UChar buffer[UFMT_DEFAULT_BUFFER_SIZE]; int32_t size = (int32_t)strlen(patternSpecification) + 1; /* convert from the default codepage to Unicode */ if (size >= MAX_UCHAR_BUFFER_SIZE(buffer)) { pattern = (UChar *)uprv_malloc(size * sizeof(UChar)); if (pattern == 0) { return 0; } } else { pattern = buffer; } u_charsToUChars(patternSpecification, pattern, size); /* do the work */ count = u_vfprintf_u(f, pattern, ap); /* clean up */ if (pattern != buffer) { uprv_free(pattern); } return count;}
开发者ID:Botyto,项目名称:Core,代码行数:36,
注:本文中的uprv_malloc函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ uprv_memcmp函数代码示例 C++ uprv_free函数代码示例 |