/
| 1486 | |
| 1487 | /*****************************************************************************/ |
| 1488 | int proj_errno_reset (const PJ *P) { |
| 1489 | /****************************************************************************** |
| 1490 | Clears errno in the context and thread local levels |
| 1491 | through the low level pj_ctx interface. |
| 1492 | |
| 1493 | Returns the previous value of the errno, for convenient reset/restore |
| 1494 | operations: |
| 1495 | |
| 1496 | int foo (PJ *P) { |
| 1497 | // errno may be set on entry, but we need to reset it to be able to |
| 1498 | // check for errors from "do_something_with_P(P)" |
| 1499 | int last_errno = proj_errno_reset (P); |
| 1500 | |
| 1501 | // local failure |
| 1502 | if (0==P) |
| 1503 | return proj_errno_set (P, 42); |
| 1504 | |
| 1505 | // call to function that may fail |
| 1506 | do_something_with_P (P); |
| 1507 | |
| 1508 | // failure in do_something_with_P? - keep latest error status |
| 1509 | if (proj_errno(P)) |
| 1510 | return proj_errno (P); |
| 1511 | |
| 1512 | // success - restore previous error status, return 0 |
| 1513 | return proj_errno_restore (P, last_errno); |
| 1514 | } |
| 1515 | ******************************************************************************/ |
| 1516 | int last_errno; |
| 1517 | last_errno = proj_errno (P); |
| 1518 | |
| 1519 | proj_context_errno_set (pj_get_ctx ((PJ *) P), 0); |
| 1520 | errno = 0; |
| 1521 | return last_errno; |
| 1522 | } |
| 1523 | |
| 1524 | |
| 1525 | /* Create a new context based on the default context */ |
no test coverage detected