[arrayfire] 136/284: af_get_last_error supports NULL as valid argument for len
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Sun Feb 7 18:59:27 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/experimental
in repository arrayfire.
commit 8813a2eff1f75f056e8dc6865595100f1fd9d16a
Author: Shehzan Mohammed <shehzan at arrayfire.com>
Date: Thu Dec 31 16:05:12 2015 -0500
af_get_last_error supports NULL as valid argument for len
---
src/api/c/err_common.cpp | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/api/c/err_common.cpp b/src/api/c/err_common.cpp
index 886e43b..382dac1 100644
--- a/src/api/c/err_common.cpp
+++ b/src/api/c/err_common.cpp
@@ -166,17 +166,21 @@ print_error(const string &msg)
void af_get_last_error(char **str, dim_t *len)
{
- *len = std::min(MAX_ERR_SIZE, (int)global_err_string.size());
+ dim_t slen = std::min(MAX_ERR_SIZE, (int)global_err_string.size());
- if (*len == 0) {
+ if (len && slen == 0) {
+ *len = 0;
*str = NULL;
+ return;
}
- af_alloc_host((void**)str, sizeof(char) * (*len + 1));
- global_err_string.copy(*str, *len);
+ af_alloc_host((void**)str, sizeof(char) * (slen + 1));
+ global_err_string.copy(*str, slen);
- (*str)[*len] = '\0';
+ (*str)[slen] = '\0';
global_err_string = std::string("");
+
+ if(len) *len = slen;
}
const char *af_err_to_string(const af_err err)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git
More information about the debian-science-commits
mailing list