From 0ae008a7ad69b79036d0d40de074d8caeb3eb4fd Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 2 Oct 2012 16:17:42 +0200 Subject: [PATCH] multi: combine both NSDs and multiple NSDs into one --- src/filter_multi.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/filter_multi.cpp b/src/filter_multi.cpp index 5efc6d3..e563b62 100644 --- a/src/filter_multi.cpp +++ b/src/filter_multi.cpp @@ -573,7 +573,7 @@ void yf::Multi::Frontend::record_diagnostics(Z_Records *records, { Z_DiagRec **n = (Z_DiagRec **) odr_malloc(odr, - (1+z_diag->num_diagRecs) * sizeof(*n)); + (1 + z_diag->num_diagRecs) * sizeof(*n)); memcpy(n, z_diag->diagRecs, z_diag->num_diagRecs * sizeof(*n)); z_diag->diagRecs = n; @@ -586,8 +586,24 @@ void yf::Multi::Frontend::record_diagnostics(Z_Records *records, } else if (records->which == Z_Records_multipleNSD) { - // we may set this multiple times (TOO BAD!) - z_diag = records->u.multipleNonSurDiagnostics; + Z_DiagRecs * dr =records->u.multipleNonSurDiagnostics; + + if (!z_diag) + { + z_diag = (Z_DiagRecs *) odr_malloc(odr, sizeof(*z_diag)); + z_diag->num_diagRecs = 0; + z_diag->diagRecs = 0; + } + Z_DiagRec **n = (Z_DiagRec **) + odr_malloc(odr, + (dr->num_diagRecs + z_diag->num_diagRecs) * + sizeof(*n)); + if (z_diag->num_diagRecs) + memcpy(n, z_diag->diagRecs, z_diag->num_diagRecs * sizeof(*n)); + memcpy(n + z_diag->num_diagRecs, + dr->diagRecs, dr->num_diagRecs * sizeof(*n)); + z_diag->diagRecs = n; + z_diag->num_diagRecs += dr->num_diagRecs; } else no_successful++; // probably piggyback -- 1.7.10.4