msInsertErrorObj() ** ** We maintain a chained list of errorObj in which the first errorObj is ** the most recent (i.e. a stack). msErrorReset() should be used to clear ** the list. ** ** Note that since some code in MapServer will fetch the head of the list and ** keep a handle on it for a while, the head of the chained list is static ** and never changes. ** A new errorObj is always inserted af
| 180 | ** the new error information. |
| 181 | */ |
| 182 | static errorObj *msInsertErrorObj(void) |
| 183 | { |
| 184 | errorObj *ms_error; |
| 185 | ms_error = msGetErrorObj(); |
| 186 | |
| 187 | if (ms_error->code != MS_NOERR) |
| 188 | { |
| 189 | /* Head of the list already in use, insert a new errorObj after the head |
| 190 | * and move head contents to this new errorObj, freeing the errorObj |
| 191 | * for reuse. |
| 192 | */ |
| 193 | errorObj *new_error; |
| 194 | new_error = (errorObj *)malloc(sizeof(errorObj)); |
| 195 | |
| 196 | /* Note: if malloc() failed then we simply do nothing and the head will |
| 197 | * be overwritten by the caller... we cannot produce an error here |
| 198 | * since we are already inside a msSetError() call. |
| 199 | */ |
| 200 | if (new_error) |
| 201 | { |
| 202 | new_error->next = ms_error->next; |
| 203 | new_error->code = ms_error->code; |
| 204 | new_error->isreported = ms_error->isreported; |
| 205 | strlcpy(new_error->routine, ms_error->routine, sizeof(new_error->routine)); |
| 206 | strlcpy(new_error->message, ms_error->message, sizeof(new_error->message)); |
| 207 | |
| 208 | ms_error->next = new_error; |
| 209 | ms_error->code = MS_NOERR; |
| 210 | ms_error->isreported = MS_FALSE; |
| 211 | ms_error->routine[0] = '\0'; |
| 212 | ms_error->message[0] = '\0'; |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | return ms_error; |
| 217 | } |
| 218 | |
| 219 | /* msResetErrorList() |
| 220 | ** |
no test coverage detected