Last change
on this file was
19431,
checked in by westram, 17 months ago
|
- fix NDEBUG warnings (gcc 10.2)
- by simplifying GB_transaction dtor (completely separates asserting from not-asserting code)
- format-overflow-warning.
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
File size:
2.2 KB
|
Line | |
---|
1 | // =============================================================== // |
---|
2 | // // |
---|
3 | // File : arbdbpp.cxx // |
---|
4 | // Purpose : // |
---|
5 | // // |
---|
6 | // Institute of Microbiology (Technical University Munich) // |
---|
7 | // http://www.arb-home.de/ // |
---|
8 | // // |
---|
9 | // =============================================================== // |
---|
10 | |
---|
11 | #include "gb_local.h" |
---|
12 | |
---|
13 | void GB_transaction::init(GBDATA *gb_main, bool initial) { |
---|
14 | ta_main = gb_main; |
---|
15 | ta_open = false; |
---|
16 | ta_err = NULp; |
---|
17 | #if defined(ASSERTION_USED) |
---|
18 | checked_for_error = 0; |
---|
19 | #endif |
---|
20 | |
---|
21 | if (ta_main) { |
---|
22 | ta_err = initial ? GB_begin_transaction(ta_main) : GB_push_transaction(ta_main); |
---|
23 | if (!ta_err) { |
---|
24 | ta_open = true; |
---|
25 | } |
---|
26 | } |
---|
27 | else { |
---|
28 | ta_err = "NULp-Transaction"; |
---|
29 | } |
---|
30 | } |
---|
31 | |
---|
32 | ARB_ERROR GB_transaction::close(ARB_ERROR& error) { |
---|
33 | return close(error.deliver()); |
---|
34 | } |
---|
35 | GB_ERROR GB_transaction::close(GB_ERROR error) { |
---|
36 | // abort transaction if error is set |
---|
37 | |
---|
38 | if (error) { |
---|
39 | if (ta_err) { |
---|
40 | ta_err = GBS_global_string("%s\n(previous error: %s)", error, ta_err); |
---|
41 | } |
---|
42 | else { |
---|
43 | ta_err = error; |
---|
44 | } |
---|
45 | } |
---|
46 | |
---|
47 | // @@@ check for exported error here (when GB_export_error gets redesigned) |
---|
48 | |
---|
49 | if (ta_open) { |
---|
50 | ta_err = GB_end_transaction(ta_main, ta_err); |
---|
51 | ta_open = false; |
---|
52 | } |
---|
53 | |
---|
54 | CFE(2); |
---|
55 | |
---|
56 | return ta_err; |
---|
57 | } |
---|
58 | |
---|
59 | GB_transaction::~GB_transaction() { |
---|
60 | #if defined(ASSERTION_USED) |
---|
61 | GB_ERROR error; |
---|
62 | if (ta_open) { |
---|
63 | LocallyModify<int> keep_checked_for_error(checked_for_error, checked_for_error); |
---|
64 | error = close(NULp); |
---|
65 | } |
---|
66 | else { |
---|
67 | error = ta_err; |
---|
68 | } |
---|
69 | |
---|
70 | if (error) { |
---|
71 | fprintf(stderr, "Error while closing transaction (checked_for_error=%i): %s\n", checked_for_error, error); |
---|
72 | if (!checked_for_error) { |
---|
73 | gb_assert(0); // you need to manually use TA.close() or check TA.ok() after opening TA |
---|
74 | } |
---|
75 | } |
---|
76 | #else // !ASSERTION_USED |
---|
77 | if (ta_open) { |
---|
78 | close(NULp); |
---|
79 | } |
---|
80 | #endif |
---|
81 | } |
---|
82 | |
---|
Note: See
TracBrowser
for help on using the repository browser.