forked from arrayfire/arrayfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.cpp
More file actions
34 lines (28 loc) · 933 Bytes
/
Copy patherror.cpp
File metadata and controls
34 lines (28 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*******************************************************
* Copyright (c) 2014, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#include <af/exception.h>
#include <af/device.h>
#include <common/err_common.hpp>
#include <string>
#include <algorithm>
void af_get_last_error(char **str, dim_t *len)
{
std::string &global_error_string = get_global_error_string();
dim_t slen = std::min(MAX_ERR_SIZE, (int)global_error_string.size());
if (len && slen == 0) {
*len = 0;
*str = NULL;
return;
}
af_alloc_host((void**)str, sizeof(char) * (slen + 1));
global_error_string.copy(*str, slen);
(*str)[slen] = '\0';
global_error_string = std::string("");
if(len) *len = slen;
}