diff options
author | John Levon <john.levon@sun.com> | 2009-02-09 14:16:23 +0000 |
---|---|---|
committer | John Levon <john.levon@sun.com> | 2009-02-09 14:16:23 +0000 |
commit | fa7f51b813518bc305a1d4231495940654570b5c (patch) | |
tree | a06c682ee811545285b4e07864da4672d581ab4f /src/virterror.c | |
parent | Limit virsh history entries to 500 (Jim Paris) (diff) | |
download | libvirt-fa7f51b813518bc305a1d4231495940654570b5c.tar.gz libvirt-fa7f51b813518bc305a1d4231495940654570b5c.tar.bz2 libvirt-fa7f51b813518bc305a1d4231495940654570b5c.zip |
introduce virSaveLastError(), virFreeError()
Diffstat (limited to 'src/virterror.c')
-rw-r--r-- | src/virterror.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/virterror.c b/src/virterror.c index 6c479f43d..42a7cf578 100644 --- a/src/virterror.c +++ b/src/virterror.c @@ -286,6 +286,27 @@ virCopyLastError(virErrorPtr to) } /** + * virSaveLastError: + * + * Save the last error into a new error object. + * + * Returns a pointer to the copied error or NULL if allocation failed. + * It is the caller's responsibility to free the error with + * virFreeError(). + */ +virErrorPtr +virSaveLastError(void) +{ + virErrorPtr to; + + if (VIR_ALLOC(to) < 0) + return NULL; + + virCopyLastError(to); + return to; +} + +/** * virResetError: * @err: pointer to the virError to clean up * @@ -303,6 +324,18 @@ virResetError(virErrorPtr err) memset(err, 0, sizeof(virError)); } +/** + * virFreeError: + * @err: error to free + * + * Resets and frees the given error. + */ +void +virFreeError(virErrorPtr err) +{ + virResetError(err); + VIR_FREE(err); +} /** * virResetLastError: |