introduce virSaveLastError(), virFreeError()

This commit is contained in:
John Levon 2009-02-09 14:16:23 +00:00
parent 1290b28f59
commit fa7f51b813
4 changed files with 47 additions and 0 deletions

View File

@ -1,3 +1,9 @@
Mon Feb 9 14:07:51 GMT 2009 John Levon <john.levon@sun.com>
* include/libvirt/virterror.h:
* src/libvirt_public.syms:
* src/virterror.c: introduce virSaveLastError(), virFreeError()
Mon Feb 9 10:21:33 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
* src/virsh.c: Limit readonly history to 500 to avoid unbounded

View File

@ -172,8 +172,10 @@ typedef void (*virErrorFunc) (void *userData, virErrorPtr error);
*/
virErrorPtr virGetLastError (void);
virErrorPtr virSaveLastError (void);
void virResetLastError (void);
void virResetError (virErrorPtr err);
void virFreeError (virErrorPtr err);
virErrorPtr virConnGetLastError (virConnectPtr conn);
void virConnResetLastError (virConnectPtr conn);

View File

@ -247,4 +247,10 @@ LIBVIRT_0.6.0 {
} LIBVIRT_0.5.0;
LIBVIRT_0.6.1 {
global:
virFreeError;
virSaveLastError;
} LIBVIRT_0.6.0;
# .... define new API here using predicted next version number ....

View File

@ -285,6 +285,27 @@ virCopyLastError(virErrorPtr to)
return to->code;
}
/**
* 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: