Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add qvi_delete(). #87

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/qvi-hwpool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,7 @@ void
qvi_hwpool_free(
qvi_hwpool_t **rpool
) {
if (!rpool) return;
qvi_hwpool_t *irpool = *rpool;
if (!irpool) goto out;
delete irpool;
out:
*rpool = nullptr;
qvi_delete(rpool);
}

int
Expand Down
16 changes: 16 additions & 0 deletions src/qvi-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@

#ifdef __cplusplus

/**
* Simple wrapper around delete that also nullifies the input pointer.
*/
template <class T>
void
qvi_delete(
T **t
) {
if (!t) return;
T *it = *t;
if (!it) goto out;
delete it;
out:
*t = nullptr;
}

/**
* Returns the code captured by a constructor. Since we are trying to avoid the
* use of exceptions, we instead use this method for checking the state of an
Expand Down
Loading