fix: fix mbs2ucs4 issue

This commit is contained in:
dapan1121 2022-07-29 19:49:45 +08:00
parent ad9581776a
commit c2e4110ae1
1 changed files with 13 additions and 0 deletions

View File

@ -161,6 +161,13 @@ void taosConvDestroy() {
}
void taosAcquireConv(int32_t *idx) {
if (0 == gConvMaxNum) {
gConv = taosMemoryCalloc(1, sizeof(SConv));
gConv[0].conv = iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset);
*idx = 0;
return;
}
while (true) {
int32_t used = atomic_add_fetch_32(&convUsed, 1);
if (used > gConvMaxNum) {
@ -189,6 +196,12 @@ void taosAcquireConv(int32_t *idx) {
}
void taosReleaseConv(int32_t idx) {
if (0 == gConvMaxNum) {
iconv_close(gConv[0].conv);
taosMemoryFreeClear(gConv);
return;
}
atomic_store_8(&gConv[idx].inUse, 0);
}