| 17 | #include <string> |
| 18 | |
| 19 | void af_get_last_error(char **str, dim_t *len) { |
| 20 | std::string &global_error_string = get_global_error_string(); |
| 21 | dim_t slen = |
| 22 | std::min(MAX_ERR_SIZE, static_cast<int>(global_error_string.size())); |
| 23 | |
| 24 | if (len && slen == 0) { |
| 25 | *len = 0; |
| 26 | *str = NULL; |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | void *halloc_ptr = nullptr; |
| 31 | af_alloc_host(&halloc_ptr, sizeof(char) * (slen + 1)); |
| 32 | memcpy(str, &halloc_ptr, sizeof(void *)); |
| 33 | global_error_string.copy(*str, slen); |
| 34 | |
| 35 | (*str)[slen] = '\0'; |
| 36 | global_error_string = std::string(""); |
| 37 | |
| 38 | if (len) { *len = slen; } |
| 39 | } |
| 40 | |
| 41 | af_err af_set_enable_stacktrace(int is_enabled) { |
| 42 | arrayfire::common::is_stacktrace_enabled() = is_enabled; |
no test coverage detected