| 97 | } |
| 98 | |
| 99 | void IllegalArgumentException::construct(const char* header, const char* extra, |
| 100 | const char* function, const char* tail) { |
| 101 | // try building the exception msg with a smallish buffer first, |
| 102 | // then with a larger one if sprintf tells us to. |
| 103 | int n = 512; |
| 104 | char* buf; |
| 105 | |
| 106 | for(;;) { |
| 107 | buf = new char[n]; |
| 108 | |
| 109 | int size; |
| 110 | if(extra == NULL) { |
| 111 | size = snprintf(buf, n, "%s\n%s\n%s", |
| 112 | header, function, tail); |
| 113 | } else { |
| 114 | size = snprintf(buf, n, "%s\n%s\n\n %s\n%s", |
| 115 | header, function, extra, tail); |
| 116 | } |
| 117 | |
| 118 | if(size < n) { |
| 119 | break; |
| 120 | } else { |
| 121 | // size >= n |
| 122 | // try again with a buffer that's large enough |
| 123 | n = size + 1; |
| 124 | delete [] buf; |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | setMessage(string(buf)); |
| 129 | |
| 130 | #ifdef CVC4_DEBUG |
| 131 | LastExceptionBuffer* buffer = LastExceptionBuffer::getCurrent(); |
| 132 | if(buffer != NULL){ |
| 133 | if(buffer->getContents() == NULL) { |
| 134 | buffer->setContents(buf); |
| 135 | } |
| 136 | } |
| 137 | #endif /* CVC4_DEBUG */ |
| 138 | delete [] buf; |
| 139 | } |
| 140 | |
| 141 | void IllegalArgumentException::construct(const char* header, const char* extra, |
| 142 | const char* function) { |
nothing calls this directly
no test coverage detected