| 54 | /************************************************************************/ |
| 55 | |
| 56 | static char *CPLGetStaticResult() |
| 57 | |
| 58 | { |
| 59 | int bMemoryError = FALSE; |
| 60 | char *pachBufRingInfo = |
| 61 | static_cast<char *>(CPLGetTLSEx(CTLS_PATHBUF, &bMemoryError)); |
| 62 | if (bMemoryError) |
| 63 | return nullptr; |
| 64 | if (pachBufRingInfo == nullptr) |
| 65 | { |
| 66 | pachBufRingInfo = static_cast<char *>(VSI_CALLOC_VERBOSE( |
| 67 | 1, sizeof(int) + CPL_PATH_BUF_SIZE * CPL_PATH_BUF_COUNT)); |
| 68 | if (pachBufRingInfo == nullptr) |
| 69 | return nullptr; |
| 70 | CPLSetTLS(CTLS_PATHBUF, pachBufRingInfo, TRUE); |
| 71 | } |
| 72 | |
| 73 | /* -------------------------------------------------------------------- */ |
| 74 | /* Work out which string in the "ring" we want to use this */ |
| 75 | /* time. */ |
| 76 | /* -------------------------------------------------------------------- */ |
| 77 | int *pnBufIndex = reinterpret_cast<int *>(pachBufRingInfo); |
| 78 | const size_t nOffset = |
| 79 | sizeof(int) + static_cast<size_t>(*pnBufIndex * CPL_PATH_BUF_SIZE); |
| 80 | char *pachBuffer = pachBufRingInfo + nOffset; |
| 81 | |
| 82 | *pnBufIndex = (*pnBufIndex + 1) % CPL_PATH_BUF_COUNT; |
| 83 | |
| 84 | return pachBuffer; |
| 85 | } |
| 86 | |
| 87 | /************************************************************************/ |
| 88 | /* CPLPathReturnTLSString() */ |
no test coverage detected