MCPcopy Create free account
hub / github.com/OSGeo/gdal / CPLGetStaticResult

Function CPLGetStaticResult

port/cpl_path.cpp:56–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54/************************************************************************/
55
56static 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() */

Callers 1

CPLPathReturnTLSStringFunction · 0.85

Calls 2

CPLGetTLSExFunction · 0.85
CPLSetTLSFunction · 0.85

Tested by

no test coverage detected