| 921 | /************************************************************************/ |
| 922 | |
| 923 | static CPLHTTPFetchContext *GetHTTPFetchContext(bool bAlloc) |
| 924 | { |
| 925 | int bError = FALSE; |
| 926 | CPLHTTPFetchContext *psCtx = static_cast<CPLHTTPFetchContext *>( |
| 927 | CPLGetTLSEx(CTLS_HTTPFETCHCALLBACK, &bError)); |
| 928 | if (bError) |
| 929 | return nullptr; |
| 930 | |
| 931 | if (psCtx == nullptr && bAlloc) |
| 932 | { |
| 933 | const auto FreeFunc = [](void *pData) |
| 934 | { delete static_cast<CPLHTTPFetchContext *>(pData); }; |
| 935 | psCtx = new CPLHTTPFetchContext(); |
| 936 | CPLSetTLSWithFreeFuncEx(CTLS_HTTPFETCHCALLBACK, psCtx, FreeFunc, |
| 937 | &bError); |
| 938 | if (bError) |
| 939 | { |
| 940 | delete psCtx; |
| 941 | psCtx = nullptr; |
| 942 | } |
| 943 | } |
| 944 | return psCtx; |
| 945 | } |
| 946 | |
| 947 | /************************************************************************/ |
| 948 | /* CPLHTTPSetFetchCallback() */ |
no test coverage detected