From: Peter Lohrmann Date: Fri, 14 Mar 2014 21:12:02 +0000 (-0700) Subject: UI: separate capturing of vogl_gl_state_snapshot from allocation of the vogleditor_gl... X-Git-Url: https://git.cworth.org/git?p=vogl;a=commitdiff_plain;h=885e25ed81807b3f9ec91db70b53621af0e003e3 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) --- 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;