| 124 | } |
| 125 | |
| 126 | const char* LastErr(void) // return the last error message, called by stasm_lasterr |
| 127 | { |
| 128 | if (!err_g[0]) // no error message? |
| 129 | { |
| 130 | // Should never get here unless someone calls LastErr or |
| 131 | // stasm_lasterr incorrectly (i.e. when there has been no error). |
| 132 | // |
| 133 | // TODO But in fact we do actually get here if cv::fastMalloc fails |
| 134 | // (within OpenCV) when allocating a small amount of memory (say 10 bytes, |
| 135 | // large amounts are ok). It seems that when there is very little memory |
| 136 | // remaining, OpenCV does not handle exceptions properly (an exception |
| 137 | // is raised but the OpenCV error callback function is not called). |
| 138 | // To reproduce, put the following in your code: |
| 139 | // volatile void *p; while (1) p = cv::fastMalloc(10); |
| 140 | |
| 141 | STRCPY(err_g, "Invalid call to LastErr"); |
| 142 | } |
| 143 | return err_g; |
| 144 | } |
| 145 | |
| 146 | void ClearLastErr(void) |
| 147 | { |