ICU-392 Don't export as many symbols with a commonly used name.
X-SVN-Rev: 6035
This commit is contained in:
parent
148353da52
commit
0bc6703321
File diff suppressed because it is too large
Load Diff
@ -112,7 +112,7 @@ static const UConverterSharedData *getAlgorithmicTypeFromName (const char *realN
|
||||
U_CAPI UConverterSharedData* U_EXPORT2 ucnv_data_unFlattenClone(UDataMemory *pData, UErrorCode *status);
|
||||
|
||||
/*initializes some global variables */
|
||||
UHashtable *SHARED_DATA_HASHTABLE = NULL;
|
||||
static UHashtable *SHARED_DATA_HASHTABLE = NULL;
|
||||
|
||||
/* The calling function uses the global mutex, so there is no need to use it here too */
|
||||
UBool ucnv_cleanup(void) {
|
||||
@ -170,7 +170,7 @@ static UConverterSharedData *createConverterFromFile (const char *fileName, UErr
|
||||
}
|
||||
|
||||
void
|
||||
copyPlatformString(char *platformString, UConverterPlatform pltfrm)
|
||||
ucnv_copyPlatformString(char *platformString, UConverterPlatform pltfrm)
|
||||
{
|
||||
switch (pltfrm)
|
||||
{
|
||||
@ -245,7 +245,8 @@ umtx_lock (NULL);
|
||||
umtx_unlock (NULL);
|
||||
}
|
||||
|
||||
UConverterSharedData *getSharedConverterData(const char *name)
|
||||
UConverterSharedData *
|
||||
getSharedConverterData(const char *name)
|
||||
{
|
||||
/*special case when no Table has yet been created we return NULL */
|
||||
if (SHARED_DATA_HASHTABLE == NULL)
|
||||
@ -267,7 +268,8 @@ umtx_unlock(NULL);
|
||||
/*frees the string of memory blocks associates with a sharedConverter
|
||||
*if and only if the referenceCounter == 0
|
||||
*/
|
||||
UBool deleteSharedConverterData(UConverterSharedData * deadSharedData)
|
||||
UBool
|
||||
deleteSharedConverterData(UConverterSharedData * deadSharedData)
|
||||
{
|
||||
if (deadSharedData->referenceCounter > 0)
|
||||
return FALSE;
|
||||
@ -363,7 +365,7 @@ parseConverterOptions(const char *inName,
|
||||
* -Call AlgorithmicConverter initializer (Data=FALSE, Cached=TRUE)
|
||||
*/
|
||||
UConverter *
|
||||
createConverter (const char *converterName, UErrorCode * err)
|
||||
ucnv_createConverter (const char *converterName, UErrorCode * err)
|
||||
{
|
||||
char cnvName[100], locale[20];
|
||||
const char *realName;
|
||||
@ -470,7 +472,8 @@ createConverter (const char *converterName, UErrorCode * err)
|
||||
return myUConverter;
|
||||
}
|
||||
|
||||
UConverterSharedData* ucnv_data_unFlattenClone(UDataMemory *pData, UErrorCode *status)
|
||||
UConverterSharedData*
|
||||
ucnv_data_unFlattenClone(UDataMemory *pData, UErrorCode *status)
|
||||
{
|
||||
/* UDataInfo info; -- necessary only if some converters have different formatVersion */
|
||||
const uint8_t *raw = (const uint8_t *)udata_getMemory(pData);
|
||||
@ -533,3 +536,43 @@ UConverterSharedData* ucnv_data_unFlattenClone(UDataMemory *pData, UErrorCode *s
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/*Frees all shared immutable objects that aren't referred to (reference count = 0)
|
||||
*/
|
||||
int32_t
|
||||
ucnv_flushCache ()
|
||||
{
|
||||
UConverterSharedData *mySharedData = NULL;
|
||||
int32_t pos = -1;
|
||||
int32_t tableDeletedNum = 0;
|
||||
const UHashElement *e;
|
||||
|
||||
/*if shared data hasn't even been lazy evaluated yet
|
||||
* return 0
|
||||
*/
|
||||
if (SHARED_DATA_HASHTABLE == NULL)
|
||||
return 0;
|
||||
|
||||
/*creates an enumeration to iterate through every element in the
|
||||
*table
|
||||
*/
|
||||
umtx_lock (NULL);
|
||||
while ((e = uhash_nextElement (SHARED_DATA_HASHTABLE, &pos)) != NULL)
|
||||
{
|
||||
mySharedData = (UConverterSharedData *) e->value;
|
||||
/*deletes only if reference counter == 0 */
|
||||
if (mySharedData->referenceCounter == 0)
|
||||
{
|
||||
tableDeletedNum++;
|
||||
|
||||
UCNV_DEBUG_LOG("del",mySharedData->staticData->name,mySharedData);
|
||||
|
||||
uhash_removeElement(SHARED_DATA_HASHTABLE, e);
|
||||
deleteSharedConverterData (mySharedData);
|
||||
}
|
||||
}
|
||||
umtx_unlock (NULL);
|
||||
|
||||
return tableDeletedNum;
|
||||
}
|
||||
|
||||
|
@ -22,98 +22,96 @@
|
||||
#include "cmemory.h"
|
||||
|
||||
/*Empties the internal unicode output buffer */
|
||||
void flushInternalUnicodeBuffer (UConverter * _this,
|
||||
void ucnv_flushInternalUnicodeBuffer (UConverter * _this,
|
||||
UChar * myTarget,
|
||||
int32_t * myTargetIndex,
|
||||
int32_t targetLength,
|
||||
int32_t** offsets,
|
||||
UErrorCode * err)
|
||||
{
|
||||
int32_t myUCharErrorBufferLength = _this->UCharErrorBufferLength;
|
||||
|
||||
if (myUCharErrorBufferLength <= targetLength)
|
||||
int32_t myUCharErrorBufferLength = _this->UCharErrorBufferLength;
|
||||
|
||||
if (myUCharErrorBufferLength <= targetLength)
|
||||
{
|
||||
/*we have enough space
|
||||
*So we just copy the whole Error Buffer in to the output stream*/
|
||||
uprv_memcpy (myTarget,
|
||||
_this->UCharErrorBuffer,
|
||||
sizeof (UChar) * myUCharErrorBufferLength);
|
||||
if (offsets)
|
||||
/*we have enough space
|
||||
*So we just copy the whole Error Buffer in to the output stream
|
||||
*/
|
||||
uprv_memcpy (myTarget,
|
||||
_this->UCharErrorBuffer,
|
||||
sizeof (UChar) * myUCharErrorBufferLength);
|
||||
if (offsets)
|
||||
{
|
||||
int32_t i=0;
|
||||
for (i=0; i<myUCharErrorBufferLength;i++) (*offsets)[i] = -1;
|
||||
*offsets += myUCharErrorBufferLength;
|
||||
int32_t i=0;
|
||||
for (i=0; i<myUCharErrorBufferLength;i++) (*offsets)[i] = -1;
|
||||
*offsets += myUCharErrorBufferLength;
|
||||
}
|
||||
*myTargetIndex += myUCharErrorBufferLength;
|
||||
_this->UCharErrorBufferLength = 0;
|
||||
*myTargetIndex += myUCharErrorBufferLength;
|
||||
_this->UCharErrorBufferLength = 0;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
/* We don't have enough space so we copy as much as we can
|
||||
* on the output stream and update the object
|
||||
* by updating the internal buffer*/
|
||||
uprv_memcpy (myTarget, _this->UCharErrorBuffer, sizeof (UChar) * targetLength);
|
||||
if (offsets)
|
||||
/* We don't have enough space so we copy as much as we can
|
||||
* on the output stream and update the object
|
||||
* by updating the internal buffer*/
|
||||
uprv_memcpy (myTarget, _this->UCharErrorBuffer, sizeof (UChar) * targetLength);
|
||||
if (offsets)
|
||||
{
|
||||
int32_t i=0;
|
||||
for (i=0; i< targetLength;i++) (*offsets)[i] = -1;
|
||||
*offsets += targetLength;
|
||||
int32_t i=0;
|
||||
for (i=0; i< targetLength;i++) (*offsets)[i] = -1;
|
||||
*offsets += targetLength;
|
||||
}
|
||||
uprv_memmove (_this->UCharErrorBuffer,
|
||||
_this->UCharErrorBuffer + targetLength,
|
||||
sizeof (UChar) * (myUCharErrorBufferLength - targetLength));
|
||||
_this->UCharErrorBufferLength -= (int8_t) targetLength;
|
||||
*myTargetIndex = targetLength;
|
||||
*err = U_BUFFER_OVERFLOW_ERROR;
|
||||
uprv_memmove (_this->UCharErrorBuffer,
|
||||
_this->UCharErrorBuffer + targetLength,
|
||||
sizeof (UChar) * (myUCharErrorBufferLength - targetLength));
|
||||
_this->UCharErrorBufferLength -= (int8_t) targetLength;
|
||||
*myTargetIndex = targetLength;
|
||||
*err = U_BUFFER_OVERFLOW_ERROR;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*Empties the internal codepage output buffer */
|
||||
void flushInternalCharBuffer (UConverter * _this,
|
||||
void ucnv_flushInternalCharBuffer (UConverter * _this,
|
||||
char *myTarget,
|
||||
int32_t * myTargetIndex,
|
||||
int32_t targetLength,
|
||||
int32_t** offsets,
|
||||
UErrorCode * err)
|
||||
{
|
||||
int32_t myCharErrorBufferLength = _this->charErrorBufferLength;
|
||||
|
||||
/*we have enough space */
|
||||
if (myCharErrorBufferLength <= targetLength)
|
||||
int32_t myCharErrorBufferLength = _this->charErrorBufferLength;
|
||||
|
||||
/*we have enough space */
|
||||
if (myCharErrorBufferLength <= targetLength)
|
||||
{
|
||||
uprv_memcpy (myTarget, _this->charErrorBuffer, myCharErrorBufferLength);
|
||||
if (offsets)
|
||||
uprv_memcpy (myTarget, _this->charErrorBuffer, myCharErrorBufferLength);
|
||||
if (offsets)
|
||||
{
|
||||
int32_t i=0;
|
||||
for (i=0; i<myCharErrorBufferLength;i++) (*offsets)[i] = -1;
|
||||
*offsets += myCharErrorBufferLength;
|
||||
int32_t i=0;
|
||||
for (i=0; i<myCharErrorBufferLength;i++) (*offsets)[i] = -1;
|
||||
*offsets += myCharErrorBufferLength;
|
||||
}
|
||||
|
||||
*myTargetIndex += myCharErrorBufferLength;
|
||||
_this->charErrorBufferLength = 0;
|
||||
|
||||
*myTargetIndex += myCharErrorBufferLength;
|
||||
_this->charErrorBufferLength = 0;
|
||||
}
|
||||
else
|
||||
/* We don't have enough space so we copy as much as we can
|
||||
* on the output stream and update the object*/
|
||||
else
|
||||
{
|
||||
uprv_memcpy (myTarget, _this->charErrorBuffer, targetLength);
|
||||
if (offsets)
|
||||
/* We don't have enough space so we copy as much as we can
|
||||
* on the output stream and update the object
|
||||
*/
|
||||
uprv_memcpy (myTarget, _this->charErrorBuffer, targetLength);
|
||||
if (offsets)
|
||||
{
|
||||
int32_t i=0;
|
||||
for (i=0; i< targetLength;i++) (*offsets)[i] = -1;
|
||||
*offsets += targetLength;
|
||||
int32_t i=0;
|
||||
for (i=0; i< targetLength;i++) (*offsets)[i] = -1;
|
||||
*offsets += targetLength;
|
||||
}
|
||||
uprv_memmove (_this->charErrorBuffer,
|
||||
_this->charErrorBuffer + targetLength,
|
||||
(myCharErrorBufferLength - targetLength));
|
||||
_this->charErrorBufferLength -= (int8_t) targetLength;
|
||||
*myTargetIndex = targetLength;
|
||||
*err = U_BUFFER_OVERFLOW_ERROR;
|
||||
uprv_memmove (_this->charErrorBuffer,
|
||||
_this->charErrorBuffer + targetLength,
|
||||
(myCharErrorBufferLength - targetLength));
|
||||
_this->charErrorBufferLength -= (int8_t) targetLength;
|
||||
*myTargetIndex = targetLength;
|
||||
*err = U_BUFFER_OVERFLOW_ERROR;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,14 +95,14 @@ typedef UConverter * (*UConverterSafeClone) (const UConverter *cnv,
|
||||
|
||||
UBool CONVERSION_U_SUCCESS (UErrorCode err);
|
||||
|
||||
void flushInternalUnicodeBuffer (UConverter * _this,
|
||||
void ucnv_flushInternalUnicodeBuffer (UConverter * _this,
|
||||
UChar * myTarget,
|
||||
int32_t * myTargetIndex,
|
||||
int32_t targetLength,
|
||||
int32_t** offsets,
|
||||
UErrorCode * err);
|
||||
|
||||
void flushInternalCharBuffer (UConverter * _this,
|
||||
void ucnv_flushInternalCharBuffer (UConverter * _this,
|
||||
char *myTarget,
|
||||
int32_t * myTargetIndex,
|
||||
int32_t targetLength,
|
||||
|
@ -23,27 +23,17 @@
|
||||
#include "unicode/utypes.h"
|
||||
#include "ucnv_bld.h"
|
||||
|
||||
#ifndef UHASH_H
|
||||
typedef struct _UHashtable UHashtable;
|
||||
#endif
|
||||
|
||||
/*Hashtable used to store UConverterSharedData objects supporting
|
||||
*the Caching mechanism
|
||||
*/
|
||||
extern UHashtable *SHARED_DATA_HASHTABLE;
|
||||
|
||||
|
||||
/* figures out if we need to go to file to read in the data tables.
|
||||
*/
|
||||
UConverter *createConverter (const char *converterName, UErrorCode * err);
|
||||
UConverter *ucnv_createConverter (const char *converterName, UErrorCode * err);
|
||||
|
||||
/* Stores the shared data in the SHARED_DATA_HASHTABLE
|
||||
*/
|
||||
void shareConverterData (UConverterSharedData * data);
|
||||
void ucnv_shareConverterData (UConverterSharedData * data);
|
||||
|
||||
/* gets the shared data from the SHARED_DATA_HASHTABLE (might return NULL if it isn't there)
|
||||
*/
|
||||
UConverterSharedData *getSharedConverterData (const char *name);
|
||||
UConverterSharedData *ucnv_getSharedConverterData (const char *name);
|
||||
|
||||
/* Deletes (frees) the Shared data it's passed. first it checks the referenceCounter to
|
||||
* see if anyone is using it, if not it frees all the memory stemming from sharedConverterData and
|
||||
@ -54,9 +44,9 @@ UBool deleteSharedConverterData (UConverterSharedData * sharedConverterData);
|
||||
|
||||
/* returns true if "name" is in algorithmicConverterNames
|
||||
*/
|
||||
UBool isDataBasedConverter (const char *name);
|
||||
UBool ucnv_isDataBasedConverter (const char *name);
|
||||
|
||||
void copyPlatformString (char *platformString, UConverterPlatform pltfrm);
|
||||
void ucnv_copyPlatformString (char *platformString, UConverterPlatform pltfrm);
|
||||
|
||||
|
||||
#endif /* _UCNV_IMP */
|
||||
|
Loading…
Reference in New Issue
Block a user