| 102 | /************************************************************************/ |
| 103 | |
| 104 | static CPLErrorContext *CPLGetErrorContext() |
| 105 | |
| 106 | { |
| 107 | int bError = FALSE; |
| 108 | CPLErrorContext *psCtx = reinterpret_cast<CPLErrorContext *>( |
| 109 | CPLGetTLSEx(CTLS_ERRORCONTEXT, &bError)); |
| 110 | if (bError) |
| 111 | return nullptr; |
| 112 | |
| 113 | if (psCtx == nullptr) |
| 114 | { |
| 115 | psCtx = static_cast<CPLErrorContext *>( |
| 116 | VSICalloc(sizeof(CPLErrorContext), 1)); |
| 117 | if (psCtx == nullptr) |
| 118 | { |
| 119 | fprintf(stderr, "Out of memory attempting to report error.\n"); |
| 120 | return nullptr; |
| 121 | } |
| 122 | psCtx->eLastErrType = CE_None; |
| 123 | psCtx->nLastErrMsgMax = sizeof(psCtx->szLastErrMsg); |
| 124 | CPLSetTLS(CTLS_ERRORCONTEXT, psCtx, TRUE); |
| 125 | } |
| 126 | |
| 127 | return psCtx; |
| 128 | } |
| 129 | |
| 130 | /************************************************************************/ |
| 131 | /* CPLGetErrorHandlerUserData() */ |
no test coverage detected