diff options
author | Jose Fonseca <jfonseca@vmware.com> | 2016-01-23 08:17:14 +0000 |
---|---|---|
committer | Jose Fonseca <jfonseca@vmware.com> | 2016-01-23 08:17:14 +0000 |
commit | faea23a42655ccd1a0d08d6ba0eb8cc45c26822b (patch) | |
tree | 165b4c194041225dbf66f37fd3a94457d8d9e505 /retrace/glretrace_main.cpp | |
parent | 39c18bddd23fe274658723cc0f6dd268cd59c36e (diff) |
glretrace: Use a ostringstream instead of asprintf.
As the latter is not portable.
Diffstat (limited to 'retrace/glretrace_main.cpp')
-rwxr-xr-x | retrace/glretrace_main.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/retrace/glretrace_main.cpp b/retrace/glretrace_main.cpp index 3f684449..254ff513 100755 --- a/retrace/glretrace_main.cpp +++ b/retrace/glretrace_main.cpp @@ -29,6 +29,7 @@ #include <string.h> #include <map> +#include <sstream> #include "retrace.hpp" #include "glproc.hpp" @@ -156,20 +157,20 @@ insertCallNoMarker(trace::Call &call, Context *currentContext) glprofile::Profile currentProfile = currentContext->actualProfile(); - char *str; - int len = asprintf(&str, "%d:%s", call.no, call.name()); - if (len > 0) { - auto pfnGlDebugMessageInsert = currentProfile.desktop() - ? glDebugMessageInsert - : glDebugMessageInsertKHR; + std::stringstream ss; + ss << call.no << ":" << call.name(); + std::string s = ss.str(); - pfnGlDebugMessageInsert(GL_DEBUG_SOURCE_THIRD_PARTY, - GL_DEBUG_TYPE_MARKER, - APITRACE_MARKER_ID, - GL_DEBUG_SEVERITY_NOTIFICATION, - len, str); - } - free(str); + auto pfnGlDebugMessageInsert = currentProfile.desktop() + ? glDebugMessageInsert + : glDebugMessageInsertKHR; + + pfnGlDebugMessageInsert(GL_DEBUG_SOURCE_THIRD_PARTY, + GL_DEBUG_TYPE_MARKER, + APITRACE_MARKER_ID, + GL_DEBUG_SEVERITY_NOTIFICATION, + s.length(), + s.c_str()); } |