From 885e25ed81807b3f9ec91db70b53621af0e003e3 Mon Sep 17 00:00:00 2001 From: Peter Lohrmann Date: Fri, 14 Mar 2014 14:12:02 -0700 Subject: [PATCH] UI: separate capturing of vogl_gl_state_snapshot from allocation of the vogleditor_gl_state_snapshot for better error reporting and memory management (cherry picked from commit 12ec6a58517055d2e460bfc0d06d1847931bf7d0) --- src/vogleditor/vogleditor_tracereplayer.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/vogleditor/vogleditor_tracereplayer.cpp b/src/vogleditor/vogleditor_tracereplayer.cpp index bc5d4f3..c7d826b 100644 --- a/src/vogleditor/vogleditor_tracereplayer.cpp +++ b/src/vogleditor/vogleditor_tracereplayer.cpp @@ -173,15 +173,20 @@ bool vogleditor_traceReplayer::recursive_replay_apicallTreeItem(vogleditor_apiCa { vogl_printf("Taking snapshot on API call # %" PRIu64 "\n", apiCallNumber); - *ppNewSnapshot = vogl_new(vogleditor_gl_state_snapshot, m_pTraceReplayer->snapshot_state()); - - if (*ppNewSnapshot == NULL) + vogl_gl_state_snapshot* pNewSnapshot = m_pTraceReplayer->snapshot_state(); + if (pNewSnapshot == NULL) { - vogl_error_printf("Snapshot failed!\n"); + vogl_error_printf("Taking new snapshot failed!\n"); } else { - vogl_printf("Snapshot succeeded\n"); + vogl_printf("Taking snapshot succeeded\n"); + *ppNewSnapshot = vogl_new(vogleditor_gl_state_snapshot, pNewSnapshot); + if (*ppNewSnapshot == NULL) + { + vogl_error_printf("Allocating memory for snapshot container failed!\n"); + vogl_delete(pNewSnapshot); + } } bStatus = false; -- 2.43.0