Commit c8b5d8e 1 parent a2906fe commit c8b5d8e Copy full SHA for c8b5d8e
File tree 2 files changed +13
-13
lines changed
2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change 130
130
qvi_hwpool_new (
131
131
qvi_hwpool_t **rpool
132
132
) {
133
- qvi_hwpool_t *irpool = qvi_new qvi_hwpool_t ();
134
- int rc = qvi_new_rc (irpool);
135
- if (rc != QV_SUCCESS) {
136
- qvi_hwpool_free (&irpool);
137
- }
138
- *rpool = irpool;
139
- return rc;
133
+ return qvi_new_rc (rpool);
140
134
}
141
135
142
136
int
Original file line number Diff line number Diff line change @@ -53,17 +53,23 @@ qvi_construct_rc(
53
53
}
54
54
55
55
/* *
56
- * Similar to qvi_construct_rc(), but is used also to check the value returned
57
- * by qvi_new .
56
+ * Constructs a new object of a given type. *t will be valid if successful,
57
+ * nullptr otherwise. Returns QV_SUCCESS if successful .
58
58
*/
59
59
template <class T >
60
60
int
61
61
qvi_new_rc (
62
- const T *const t
62
+ T ** t
63
63
) {
64
- // qvi_new must have returned nullptr.
65
- if (!t) return QV_ERR_OOR;
66
- return t->qvim_rc ;
64
+ T *it = qvi_new T ();
65
+ if (!it) return QV_ERR_OOR;
66
+
67
+ const int rc = qvi_construct_rc (*it);
68
+ if (rc != QV_SUCCESS) {
69
+ qvi_delete (&it);
70
+ }
71
+ *t = it;
72
+ return rc;
67
73
}
68
74
69
75
#endif
You can’t perform that action at this time.
0 commit comments